kinto-admin icon indicating copy to clipboard operation
kinto-admin copied to clipboard

TypeError: can't access property "id", bucket.data is undefined

Open grahamalama opened this issue 3 years ago • 1 comments

Steps to reproduce:

  • navigate to https://kinto.github.io/kinto-admin/ (or use local build to point at demo server)
  • Log in with anonymous auth
  • There should be one bucket visible f8ba1b65-d87b-f57a-8e22-0f731d957e68 with a collection test. Click on the test collection (or navigate directly to /#/buckets/f8ba1b65-d87b-f57a-8e22-0f731d957e68/collections/test/records)

Expected: Something is rendered to the screen (either records, or some error message if no records are present) Actual: White screen. When using Devtools on the local build of kinto-admin, the following error messages appear:

Uncaught TypeError: can't access property "id", bucket.data is undefined
...
The above error occurred in the <ListActions> component:
...

grahamalama avatar Mar 16 '22 19:03 grahamalama

The bucket is not readable anonymously:

http https://demo.kinto-storage.org/v1/buckets/f8ba1b65-d87b-f57a-8e22-0f731d957e68
HTTP/1.1 401 Unauthorized
....
{
    "code": 401,
    "errno": 104,
    "error": "Unauthorized",
    "message": "Please authenticate yourself to use this endpoint."
}

But the collection is:

http https://demo.kinto-storage.org/v1/buckets/f8ba1b65-d87b-f57a-8e22-0f731d957e68/collections/test
HTTP/1.1 200 OK
....
{
    "data": {
        "attachment": {
            "enabled": false,
            "required": false
        },
        "cache_expires": 0,
        "displayFields": [
            "title"
        ],
        "id": "test",
        "last_modified": 1634629772258,
        "schema": {
            "properties": {
        ....

The bucket object in the state is thus empty, and I suspect this code to assume it isn't. In that case the bucket id can be taken from the match prop instead (which is populated from URL hash)

leplatrem avatar Mar 17 '22 10:03 leplatrem