fix(cli): fail loudly on a truncated introspection type-ref - #279
Open
thedavidmeister wants to merge 3 commits into
Open
fix(cli): fail loudly on a truncated introspection type-ref#279thedavidmeister wants to merge 3 commits into
thedavidmeister wants to merge 3 commits into
Conversation
The introspection query resolved four type-ref levels and render_type rendered anything past that as `Unknown`, so a wrapper chain the server truncated came back as a type the deployed schema does not have and the check reported a mismatch that was not there. Build the query from TYPE_REF_DEPTH (8, the reference introspection depth) and make an unresolvable ref an error naming the field, so the depth assumption is asserted in code rather than assumed. Closes #200 Closes #222 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 56 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #200
Closes #222
The defect
INTROSPECTION_QUERYasked the server for four type-ref levels:type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }A wrapper chain longer than that comes back with the innermost
ofTypecut off, and
render_typeturned that cut-off level into the literalUnknownvianame.unwrap_or("Unknown").checkthen compared theinvented type against the consumer snapshot and reported a mismatch that
did not exist, naming a type the deployed schema never had.
Confirmed on
origin/main(45ca96c) with a probe test feedingfetch_live_entities_as_sdla mocked response with the innermostofTypecut off:Base returns
Okand produces the spurious mismatch, exactly as #200describes.
#222 is the same cap, and adds the part that decides the fix: nothing in
the code asserted the backend's type depth, so the 4-level assumption was
invisible either way.
The fix
The query is built from
TYPE_REF_DEPTH(8, the depth the referenceintrospection query settled on), and
render_typereturns aResult. Awrapper with no
ofType, or a named ref with no name, is now an errornaming the field:
The
Unknownplaceholder is gone. GraphQL puts no bound on wrapperchains, so no depth is provably enough; the point is that past the cap
the command now fails with the reason instead of silently comparing an
invented type against the snapshot.
QA
fetch_live_entities_errors_on_a_truncated_type_ref,render_type_errors_on_a_truncated_wrapper_chain,render_type_errors_on_missing_name,introspection_query_is_valid_graphql_nested_to_the_declared_depth-each fails on base (verified by checking
origin/mainout into aworktree and running the probe above: base returns
Okwhere thesetests
unwrap_err(), and base'srender_typereturnsString, so theUnknownplaceholder these assert against is what base actuallyproduces).
of_type: drop.filter(|v| !v.is_null())-> killed byrender_type_errors_on_a_truncated_wrapper_chainandfetch_live_entities_errors_on_a_truncated_type_refrender_typeLIST arm:"[{}]"->"{}"-> killed byrender_type_unwraps_introspection_typeref_recursivelyandrender_type_round_trips_a_chain_at_the_query_depthrender_typeNON_NULL arm:"{}!"->"{}"-> killed by those twoplus
fetch_live_entities_filters_to_entity_object_typesok_or_else(...)->unwrap_or("Unknown")-> killed byrender_type_errors_on_missing_namefetch_live_entities_as_sdl: drop the field-namingmap_err->killed by
fetch_live_entities_errors_on_a_truncated_type_ref1..TYPE_REF_DEPTH->2..TYPE_REF_DEPTH-> killed byintrospection_query_is_valid_graphql_nested_to_the_declared_depthTYPE_REF_DEPTH8 -> 4, and 8 -> 3. Not killable fromin-repo evidence: graph-node's entity type model tops out at
[X!]!= 4 levels, and
subgraph/schema.graphql's deepest field ismetas: [MetaV1!]= 3, so no oracle here distinguishes 4 from 8. Thedepth above 4 is margin for the non-graph-node backends schema_check introspection query caps type nesting at 4 ofType levels; deeper wrapper types silently render as Unknown and report false mismatches #222 raises,
which nothing in this repo can assert. What the tests do pin is that
truncation at whatever depth fails loudly instead of rendering
Unknown- the behaviour that caused the false positive. A literalassert!(TYPE_REF_DEPTH >= 4)was tried and dropped: clippy rejectsit as
this assertion has a constant value, which is the correctverdict - it pins nothing.
chain (NON_NULL ->
X!, LIST ->[X]), not read off theimplementation; and
graphql_parser::query::parse_queryfor thegenerated query's validity. The query is assembled from a format string
now and the mocked tests never parse it, so nothing else would have
caught a malformed one - the brace balance is checked by a real parser
rather than by eye.
Unknownand stop producing false mismatches (covered: the error pathplus the end-to-end repro test); schema_check introspection query caps type nesting at 4 ofType levels; deeper wrapper types silently render as Unknown and report false mismatches #222 asks additionally that the depth
assumption be asserted rather than assumed (covered: the cap is now a
named constant the query is generated from, and exceeding it is a hard
error naming the field, rather than a comment pinning an assumption).
cargo test -p rain-metadata --lib cli::schema_check: 38 passed.cargo fmt --checkandcargo clippy -p rain-metadata --all-targets -D warningsclean. The full suite was not run locally; CI covers it.
🤖 Generated with Claude Code