Repository navigation
Only treat a top-level NOT_FOUND GraphQL error as a missing resource - #2937
Merged
Merged
Conversation
Dry-run check results |
marcoieni
force-pushed
the
graphql-opt-root-not-found
branch
3 times, most recently
from
November 11, 2026 14:24
d67b03c to
61f8837
Compare
marcoieni
force-pushed
the
graphql-opt-root-not-found
branch
from
November 11, 2026 15:41
4a3764a to
5f77e81
Compare
marcoieni
reviewed
Nov 11, 2026
|
|
||
| if let Some(error) = res.errors.first() { | ||
| bail!("graphql error: {}", error.message); | ||
| } |
Member
There was a problem hiding this comment.
I moved this check to line 248
| return Ok(None); | ||
| } | ||
| bail!("graphql error: {}", error.message); | ||
| } |
Member
There was a problem hiding this comment.
this check is done differently in line 256
marcoieni
marked this pull request as ready for review
November 11, 2026 15:42
marcoieni
requested review from
Mark-Simulacrum,
emilyalbini,
jdno and
ubiratansoares
as code owners
November 11, 2026 15:42
jieyouxu
reviewed
Nov 13, 2026
Comment on lines
+861
to
+866
| #[test] | ||
| fn graphql_opt_fails_on_missing_data_without_errors() { | ||
| // Only a `NOT_FOUND` error proves that the resource is missing, not the lack of data. | ||
| let error = read_opt_err(json!({ "data": null })); | ||
| assert_eq!(error, "missing graphql data"); | ||
| } |
Member
There was a problem hiding this comment.
Hm, I'm a bit confused by this test name. Isn't read_opt_error still doing .unwrap_err (i.e. there is an error)? Or is this supposed to mean that the error message doesn't say "Could not resolve" etc.?
EDIT: Oh, I think this means the { "data": ..., "errors": [] }, rather than.. the error 😆
jieyouxu
approved these changes
Nov 13, 2026
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.
graphql_optreturnedOk(None)("the repository doesn't exist") whenever the first GraphQL error had typeNOT_FOUND. ANOT_FOUNDerror on a nested field could therefore make an existing repository look missing.GitHub's GraphQL errors include a
pathpointing to the field that failed. With this PR,graphql_optreturnsOk(None)only if every error is aNOT_FOUNDwhose path points to a top-level field (e.g.["repository"]). Any other error is returned as anErr.This is useful because #2936 adds new fields to that query. If those fields are null, then we shouldn't say that the repository doesn't exist.
AI disclosure
I used Opus 5.5 to generate this change. I reviewed its output and changed it where necessary.