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

feat: add UUID validation so errors are raised earlier #652

Merged
merged 1 commit into from Sep 8, 2020
Merged

Conversation

benjie
Copy link
Member

@benjie benjie commented Sep 8, 2020

Previously if a user submitted a query, passing an invalid UUID value such as "undefined" or "27", we would pass this through to Postgres as a string, and have Postgres cast it to UUID, which fails at runtime, causing the entire SQL query to fail within the database. This may cause GraphQL clients to make invalid assumptions about the data since the error occurs at the root field rather than the nested field, potentially triggering a client to update their cache to say that root field is invalid.

This PR solves this by making sure that we'd expect PostgreSQL to be able to coerce the value to UUID before actually passing it to PostgreSQL, throwing a scalar coercion error otherwise and not allowing the query to reach the database.

Fixes #644

@benjie benjie merged commit 9265262 into v4 Sep 8, 2020
@benjie benjie deleted the uuid-validation branch September 8, 2020 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insufficient validation of UUID type
1 participant