Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 500 on patch_group (KeyError) #2688

Open
AlexB1986 opened this issue Dec 21, 2020 · 8 comments
Open

HTTP 500 on patch_group (KeyError) #2688

AlexB1986 opened this issue Dec 21, 2020 · 8 comments
Assignees
Labels
bug easy-pick stale For marking issues as stale. Labeled issues will be closed soon if label is not removed.

Comments

@AlexB1986
Copy link

AlexB1986 commented Dec 21, 2020

Steps to reproduce
docker run -p 8888:8888 kinto/kinto-server
Running kinto 14.0.1.dev0.

First request

POST /v1/buckets HTTP/1.1
Host: 127.0.0.1:8888
Authorization: Basic AAAA
Content-Type: application/json
Content-Length: 222

{"data": {"collection:schema": {}, "group:schema": {}, "record:schema": {}}, "permissions": {"collection:create": ["write_account"], "group:create": ["write_account"], "read": ["read_account"], "write": ["write_account"]}}

First response HTTP 201

{
    "permissions": {
        "read": [
            "read_account"
        ],
        "write": [
            "write_account",
            "account:admin"
        ],
        "collection:create": [
            "write_account"
        ],
        "group:create": [
            "write_account"
        ]
    },
    "data": {
        "collection:schema": {},
        "group:schema": {},
        "record:schema": {},
        "id": "6UULOFrV",
        "last_modified": 1608558398847
    }
}

Second request

PUT /v1/buckets/6UULOFrV/groups/0 HTTP/1.1
Host: 127.0.0.1:8888
User-Agent: python-requests/2.24.0
Accept-Encoding: gzip,deflate
Response-Behavior: diff
If-None-Match: "0"
Authorization: Basic AAAA
Content-Type: application/json
Content-Length: 83

{"data": {}, "permissions": {"read": ["read_account"], "write": ["write_account"]}}

Second response HTTP 201

{
    "permissions": {
        "read": [
            "read_account"
        ],
        "write": [
            "write_account",
            "account:admin"
        ]
    },
    "data": {
        "members": [],
        "id": "0",
        "last_modified": 1608558411303
    }
}

Third request

PATCH /v1/buckets/6UULOFrV/groups/0 HTTP/1.1
Host: 127.0.0.1:8888
User-Agent: python-requests/2.24.0
Accept-Encoding: gzip,deflate
Response-Behavior: diff
If-None-Match: "0"
Authorization: Basic AAAA
Content-Type: application/json
Content-Length: 83

{"data": {}, "permissions": {"read": ["read_account"], "write": ["write_account"]}}

Third response HTTP 500

{
    "code": 500,
    "errno": 999,
    "error": "Internal Server Error",
    "message": "A programmatic error occured, developers have been informed.",
    "info": "https://github.com/Kinto/kinto/issues/"
}

Log

"PATCH /v1/buckets/6UULOFrV/groups/0?" ? (? ms) 'id' errno=999

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pyramid/tweens.py", line 41, in excview_tween
response = handler(request)
File "/app/kinto/core/events.py", line 159, in tween
request.registry.notify(event)
File "/usr/local/lib/python3.7/site-packages/pyramid/registry.py", line 109, in notify
[_ for _ in self.subscribers(events, None)]
File "/usr/local/lib/python3.7/site-packages/zope/interface/registry.py", line 448, in subscribers
return self.adapters.subscribers(objects, provided)
File "/usr/local/lib/python3.7/site-packages/zope/interface/adapter.py", line 619, in subscribers
subscription(*objects)
File "/usr/local/lib/python3.7/site-packages/pyramid/config/adapters.py", line 129, in subscriber_wrapper
return derived_subscriber(*arg)
File "/usr/local/lib/python3.7/site-packages/pyramid/config/adapters.py", line 101, in derived_subscriber
return subscriber(arg[0])
File "/app/kinto/views/groups.py", line 79, in on_groups_changed
group_uri = f"/buckets/{event.payload['bucket_id']}/groups/{group['id']}"
KeyError: 'id'
"PATCH /v1/buckets/6UULOFrV/groups/0?" 500 (7 ms) agent=python-requests/2.24.0 authn_type=account errno=999 time=2020-12-21T12:47:57.573000 uid=admin
@saurabh3796
Copy link

Can I take this? @leplatrem

@leplatrem
Copy link
Contributor

Sure!

@Sherry3
Copy link

Sherry3 commented Jan 23, 2022

@saurabh3796 are you working on fixing this issue? If not then I would like to try to fix it. @leplatrem Is this OK?
I am new to open source community, so don't know the exact practices. Please guide me.
This one seems to be easy one and I don't see any recent activity, hence I wanted to work on it.

@leplatrem
Copy link
Contributor

leplatrem commented Jan 24, 2022

Seeing that @saurabh3796 hasn't given news since September, it seems pretty reasonable for you to give it a try :) Don't hesitate to open a pull-request even if your code is not ready or not working. This way we can guide you from there

@MBhartiya
Copy link

@AlexB1986 @leplatrem I tried recreating this issue, running via
docker run -p 8888:8888 kinto/kinto-server with kinto/kinto-server:latest being higher than 14.3.0.
I created an admin account and tried to reproduce but always got 200.

"PUT   /v1/buckets/3bq7Tn1d/groups/0?" 201 (530 ms)  agent=PostmanRuntime/7.29.0 authn_type=account errno=0 time=2022-04-09T05:11:30.846000 uid=admin
"PATCH /v1/buckets/3bq7Tn1d/groups/0?" 200 (26 ms)  agent=PostmanRuntime/7.29.0 authn_type=account errno=0 time=2022-04-09T05:11:44.587000 uid=admin
"PATCH /v1/buckets/3bq7Tn1d/groups/0?" 200 (25 ms)  agent=PostmanRuntime/7.29.0 authn_type=account errno=0 time=2022-04-09T05:11:47.989000 uid=admin
"PATCH /v1/buckets/3bq7Tn1d/groups/0?" 200 (23 ms)  agent=PostmanRuntime/7.29.0 authn_type=account errno=0 time=2022-04-09T05:11:48.908000 uid=admin
"PATCH /v1/buckets/3bq7Tn1d/groups/0?" 200 (20 ms)  agent=PostmanRuntime/7.29.0 authn_type=account errno=0 time=2022-04-09T05:11:49.867000 uid=admin

I think this issue does not exist anymore.

@mohamedBenHachme
Copy link

Hello @leplatrem is this issue still exists, if so I would like to fix it;
P.S : this will be my first contribution to the open source 😄

@leplatrem
Copy link
Contributor

I think this issue does not exist anymore.

Apparently it cannot be reproduced. I tried as well with the following steps:

$ git checkout 14.0.0`
$ kinto start

And then:

$ echo '{"data":{"password":"s3cr3t"}}' | http PUT :8888/v1/accounts/admin -a admin:s3cr3t

$ http PUT :8888/v1/buckets/a -a admin:s3cr3t

$ http PUT :8888/v1/buckets/a/groups/0 -a admin:s3cr3t

$ echo '{"data":{}, "permissions":{"read": ["read_account"], "write": ["write_account"]}}' | http PATCH :8888/v1/buckets/a/groups/0 'If-None-Match: "0"' -a admin:s3cr3t
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Backoff, Alert, Content-Type, Retry-After, Content-Length
Content-Length: 144
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none'; 
Content-Type: application/json
Date: Wed, 13 Apr 2022 14:08:32 GMT
Etag: "1649858912280"
Last-Modified: Wed, 13 Apr 2022 14:08:32 GMT
Server: waitress
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "0",
        "last_modified": 1649858912280,
        "members": []
    },
    "permissions": {
        "read": [
            "read_account"
        ],
        "write": [
            "account:admin",
            "write_account"
        ]
    }
}

@mohamedBenHachme
Copy link

I think this issue does not exist anymore.

Apparently it cannot be reproduced. I tried as well with the following steps:

$ git checkout 14.0.0`
$ kinto start

And then:

$ echo '{"data":{"password":"s3cr3t"}}' | http PUT :8888/v1/accounts/admin -a admin:s3cr3t

$ http PUT :8888/v1/buckets/a -a admin:s3cr3t

$ http PUT :8888/v1/buckets/a/groups/0 -a admin:s3cr3t

$ echo '{"data":{}, "permissions":{"read": ["read_account"], "write": ["write_account"]}}' | http PATCH :8888/v1/buckets/a/groups/0 'If-None-Match: "0"' -a admin:s3cr3t
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Backoff, Alert, Content-Type, Retry-After, Content-Length
Content-Length: 144
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none'; 
Content-Type: application/json
Date: Wed, 13 Apr 2022 14:08:32 GMT
Etag: "1649858912280"
Last-Modified: Wed, 13 Apr 2022 14:08:32 GMT
Server: waitress
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "0",
        "last_modified": 1649858912280,
        "members": []
    },
    "permissions": {
        "read": [
            "read_account"
        ],
        "write": [
            "account:admin",
            "write_account"
        ]
    }
}

Okay thanks, can you suggest an issue that I can work on as I said this will be my first contribution; thanks in advance.

@alexcottner alexcottner added the stale For marking issues as stale. Labeled issues will be closed soon if label is not removed. label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy-pick stale For marking issues as stale. Labeled issues will be closed soon if label is not removed.
Projects
None yet
Development

No branches or pull requests

7 participants