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

graphql: Convert empty UUID strings to NullUUID #3744

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

mastercactapus
Copy link
Member

Description:
This update changes the use of permission.UserID to permission.UserNullUUID (a new helper), which will pass NULL instead of an empty string to Postgres when the current context isn't owned by a user.

Which issue(s) this PR fixes:
Fixes #3662

Describe any introduced user-facing changes:
N/A

Describe any introduced API changes:
N/A

Additional Info:
The issue turned out to have nothing to do with data races or GraphQL variables; instead, it was due to many store methods fetching favorites information (which is user-id specific) by passing permission.UserID() (which returns a string) directly to the DB call.

This broke when no UserID was associated with the context (as in GQL API keys, which are anonymous) because it would pass an empty string, which is not a valid UUID.

The fix was to switch to uuid.NullUUID, which has a nullable state. A new helper method, permission.UserNullUUID, was added, and call sites were updated to use it rather than UserID() for store methods.

@mastercactapus mastercactapus changed the title graphql: Convert empty UUIDs to NullUUID graphql: Convert empty UUID strings to NullUUID Mar 12, 2024
@ethan-haynes ethan-haynes merged commit 6f53c61 into master Mar 12, 2024
7 checks passed
@ethan-haynes ethan-haynes deleted the gql-api-duplicate-var-issue branch March 12, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected Error with GraphQL Query When Using Service Dataloader
3 participants