kjk / notionapi

Unofficial Go API for Notion.so
https://blog.kowalczyk.info/article/c9df78cbeaae4e0cb2848c9964bcfc94/using-notion-api-go-client.html
BSD 2-Clause "Simplified" License
1.82k stars 86 forks source link

fix: support Notion workspace with integrations #47

Closed moul closed 2 years ago

moul commented 2 years ago

when a workspace has some integrations installed, the API starts replying non-string roles, i.e.,

"permissions": [
            {
              "role": "editor",
              "type": "user_permission",
              "user_id": "ac5ed586-34a9-4722-b67e-e895c19edcaf"
            },
            {
              "added_timestamp": 1636035411376,
              "allow_duplicate": false,
              "role": "reader",
              "type": "public_permission"
            },
            {
              "role": "read_and_write",
              "type": "user_permission",
              "user_id": "a1a2a6fd-014d-443f-a166-8ce0854d6171"
            },
            {
              "role": "read_and_write",
              "type": "user_permission",
              "user_id": "5f9fc67b-8698-4cc6-ae25-8d4380f3908d"
            },
            {
              "bot_id": "1ea56cbf-1184-4d93-a7ec-2809675f0737",
              "role": {
                "insert_content": true,
                "read_content": true,
                "update_content": true
              },
              "type": "bot_permission"
            },
            {
              "bot_id": "01961fb4-378b-4627-b63d-5d5eb7c33e09",
              "parent_id": "79d995df-6706-4499-8402-9c23d1b91c89",
              "parent_table": "space",
              "role": {
                "read_content": true
              },
              "type": "bot_permission"
            },
kjk commented 2 years ago

Could you also fix the test: https://github.com/kjk/notionapi/runs/5169622956?check_suite_focus=true

goroutine 1 [running]:
github.com/kjk/u.PanicIf(0x1, 0x0, 0x0, 0x0)
    /home/runner/go/pkg/mod/github.com/kjk/u@v0.0.0-20210327060556-13ea33918991/util.go:42 +0x145
main.testQueryCollection()
    /home/runner/work/notionapi/notionapi/do/sanity.go:64 +0x2a8
main.sanityTests()
    /home/runner/work/notionapi/notionapi/do/sanity.go:[79](https://github.com/kjk/notionapi/runs/5169622956?check_suite_focus=true#step:5:79) +0x6f
main.main()
    /home/runner/work/notionapi/notionapi/do/main.go:303 +0x10d3

To run the test locally: ./do/do.sh -sanity

moul commented 2 years ago

I’ve the same error on master, I don’t think that it comes from my PR; since I’m not very aware of your testing system; can you check if you think it can come from elsewhere first?

Thank you very much

kjk commented 2 years ago

You're right, I disabled the failing test.