Permissions: TypeError: Cannot read properties of null (reading 'schema')
Version Information
Server Version: v2.30.1
Environment
OSS
What is the current behaviour?
Getting this error when I try to reference a specific relation in the permissions json. As soon as i type {"relation":{}} in the permissions json the page crashes and I get this. This seems to happen only on relationships based on more than one column.
TypeError: Cannot read properties of null (reading 'schema')
at o (https://graphql-engine-cdn.hasura.io/console/assets/channel/stable/v2.30/main.4b70ba0818cc58d1.js.gz:50:349934)
at o (https://graphql-engine-cdn.hasura.io/console/assets/channel/stable/v2.30/main.4b70ba0818cc58d1.js.gz:50:349436)
at https://graphql-engine-cdn.hasura.io/console/assets/channel/stable/v2.30/main.4b70ba0818cc58d1.js.gz:50:350065
at Array.forEach (
How to reproduce the issue?
- Create a composite foreign key.
- Create a relation based on that key.
- Try to reference that relation in the permissions "custom check" for any action.
Screenshots or Screencast
Please provide any traces or logs that could help here.
There are no errors in the server log.
Any possible solutions/workarounds you're aware of?
No
Keywords
Just the error message, found no results.
Exact same problem on v2.23.0 and v2.35.1
This only happens with composite foreign keys when creating a permission and reference to this composite key. If you do not use foreign keys and create relationships manually, this does not happen. But that is not good when I can't use foreign keys because of this.
👍 Same thing over here!
👍 Same thing over here!
any workaround?
Manually change the way your relationships are specified in your metadata to this format @iamolegga
"using": {
"manual_configuration": {
"column_mapping": {
"company_id": "company_id",
"location_id": "id"
},
"insertion_order": null,
"remote_table": {
"name": "locations",
"schema": "public"
}
}
}
@sampbarrow thanks, I've solved this temporary with creating generated columns for both tables, yucky
Hey @sampbarrow, we have fixed this issue. The fix will be available from v2.45.
You can now create permissions that involve composite foreign keys in your relationship definitions. Let me know if you run into any issues!