Repository navigation
Drop write validators from generated filter schemas - #44
Merged
Merged
Conversation
generate_filter_schema cloned base-schema fields together with their validate= chain, so a query filter inherited write-time rules (Regexp, Length, Range, custom callables). Filtering by a stored value that predates a newly added rule then returned 422, making those rows unreachable through the very filter that should find them. _clone_field now clears validators on every cloned filter field: preserved equality fields and __from/__to/__min/__max variants alike. Filtering by an arbitrary value is always safe (it matches nothing); field-type coercion still applies, and the page/page_size bounds are defined separately and unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
generate_filter_schemaclones base-schema fields together with theirvalidate=chain, so query filter parameters inherit write-time rules (Regexp, Length, Range, custom callables). When a validator is added after rows already hold non-conforming values, filtering by the stored value returns 422 — the rows become unreachable through the very filter meant to find them.Concrete case: iaoport added an IMO format+checksum validator to
VesselAutoSchema; a pre-existing row withimo='23573'can no longer be looked up viaGET /api/vessel/?imo=23573.Fix
_clone_fieldnow clearsvalidatorson every cloned filter field — preserved equality fields and__from/__to/__min/__maxvariants alike. Filtering by an arbitrary value is always safe: it simply matches nothing. Field-type coercion still applies, and thepage/page_sizebounds are defined separately and unaffected.Tests
New unit test covers the preserved equality field (Regexp + custom checksum callable) and the suffixed numeric clones (Range). Full suite green.