Skip to content

fix(query): Catch Django ValidationError for malformed query values#60

Merged
mvaled merged 1 commit into
masterfrom
fix-query-validationerror
Jun 9, 2026
Merged

fix(query): Catch Django ValidationError for malformed query values#60
mvaled merged 1 commit into
masterfrom
fix-query-validationerror

Conversation

@mvaled

@mvaled mvaled commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Resolving a Model-typed Query field from its PK runs Model.objects.filter(pk=value). A value the PK field cannot parse (e.g. a non-UUID string for a UUIDField) raises Django's ValidationError, which is not a subclass of ValueError, so QueryPatcher's except ValueError let it escape: a stray ?param=garbage in the URL raised during component build and returned an HTTP 500.

Broaden both validation sites (get_update_for_state and get_updates_for_params) to also catch ValidationError and fall back to the field default. Add regression tests covering both methods.

Resolving a Model-typed `Query` field from its PK runs
`Model.objects.filter(pk=value)`.  A value the PK field cannot parse (e.g. a
non-UUID string for a `UUIDField`) raises Django's `ValidationError`, which is
not a subclass of `ValueError`, so `QueryPatcher`'s `except ValueError` let it
escape: a stray `?param=garbage` in the URL raised during component build and
returned an HTTP 500.

Broaden both validation sites (`get_update_for_state` and
`get_updates_for_params`) to also catch `ValidationError` and fall back to the
field default.  Add regression tests covering both methods.
@mvaled mvaled merged commit 45a137d into master Jun 9, 2026
3 checks passed
@mvaled mvaled deleted the fix-query-validationerror branch June 9, 2026 08:52
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

Successfully merging this pull request may close these issues.

1 participant