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

Notion crashes when setting CollectionView filter with no id #379

Open
emmby opened this issue Oct 26, 2022 · 2 comments
Open

Notion crashes when setting CollectionView filter with no id #379

emmby opened this issue Oct 26, 2022 · 2 comments

Comments

@emmby
Copy link

emmby commented Oct 26, 2022

I have a collection view that I want to set a filter on. Doing the following works just fine:


        view.set('format', {
             ...
            "property_filters": [
                {
                    "filter": {
                        "filter": {
                            "value": {
                                "type": "exact",
                                "value": <relationid>
                            },
                            "operator": "relation_contains"
                        },
                        "property": "MRxh"
                    }
                }
            ]
        })

...with the one exception that the notion page itself will crash if the user tries to modify the filter in notion. The filter works, it filters as expected, but if the user tries to change it in notion, notion shows the following error:

image

The page stops crashing if I use an ID for the filter:

            # This no longer crashes
            "property_filters": [
                {
                    "id": "d7fb...c01",
                    "filter": {
                        "filter": {
                            "value": {
                                "type": "exact",
                                "value": <relationid>
                            },
                            "operator": "relation_contains"
                        },
                        "property": "MRxh"
                    }
                }
            ]

So apparently IDs are required when setting property filters on a view. The question is, how do I generate the ID programmatically? Or should I be setting the filter a different way?

@emmby
Copy link
Author

emmby commented Oct 26, 2022

I tried using view.build_query() to generate a filter, but that filter didn't have an ID either.

@emmby
Copy link
Author

emmby commented Oct 26, 2022

I was able to work around the problem by generating random ids using secrets.token_hex(16), but I don't know how stable a solution this is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant