Skip to content

Only treat a top-level NOT_FOUND GraphQL error as a missing resource - #2937

Merged
jieyouxu merged 1 commit into
rust-lang:mainfrom
marcoienibot:graphql-opt-root-not-found
Nov 13, 2026
Merged

jieyouxu merged 1 commit into
rust-lang:mainfrom
marcoienibot:graphql-opt-root-not-found

Conversation

@marcoienibot

@marcoienibot marcoienibot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

graphql_opt returned Ok(None) ("the repository doesn't exist") whenever the first GraphQL error had type NOT_FOUND. A NOT_FOUND error on a nested field could therefore make an existing repository look missing.

GitHub's GraphQL errors include a path pointing to the field that failed. With this PR, graphql_opt returns Ok(None) only if every error is a NOT_FOUND whose path points to a top-level field (e.g. ["repository"]). Any other error is returned as an Err.

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.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Dry-run check results

[WARN  rust_team::sync] sync-team is running in dry mode, no changes will be applied.
[INFO  rust_team::sync] synchronizing crates-io
[INFO  rust_team::sync] synchronizing github
[INFO  rust_team::sync] Rate limits before: REST 15000/15000 remaining, resets at 2026-11-11 16:47:07 UTC, GraphQL 12500/12500 remaining, resets at 2026-11-11 16:47:07 UTC
[INFO  rust_team::sync] Rate limits after: REST 14526/15000 remaining, resets at 2026-11-11 16:47:18 UTC, GraphQL 12408/12500 remaining, resets at 2026-11-11 16:47:09 UTC
[INFO  rust_team::sync] Consumed 474 REST calls and 92 GraphQL calls

@marcoieni
marcoieni force-pushed the graphql-opt-root-not-found branch 3 times, most recently from d67b03c to 61f8837 Compare November 11, 2026 14:24
@marcoieni
marcoieni force-pushed the graphql-opt-root-not-found branch from 4a3764a to 5f77e81 Compare November 11, 2026 15:41

if let Some(error) = res.errors.first() {
bail!("graphql error: {}", error.message);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this check to line 248

return Ok(None);
}
bail!("graphql error: {}", error.message);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is done differently in line 256

@marcoieni
marcoieni marked this pull request as ready for review November 11, 2026 15:42

@jieyouxu jieyouxu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor test name nit since it was confusing me, but general logic seems fine to me.

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");
}

@jieyouxu jieyouxu Nov 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
jieyouxu added this pull request to the merge queue Nov 13, 2026
Merged via the queue into rust-lang:main with commit 2f102af Nov 13, 2026
5 checks passed
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.

3 participants