Skip to content

fix: retry github graphql responses whose root fields are all null - #4995

Merged
mbani01 merged 1 commit into
mainfrom
fix/github-graphql-null-root-retry
Oct 16, 2026
Merged

mbani01 merged 1 commit into
mainfrom
fix/github-graphql-null-root-retry

Conversation

@mbani01

@mbani01 mbani01 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

A Temporal alert on 2026-10-15 16:50Z (sync-run/github/issue-comments/cockroachdb/cockroach) failed with TypeError: Cannot read properties of null (reading 'issue') at issueComments.ts:62.

GitHub answered one paginated issue-comments query with errors: [NOT_FOUND "Could not resolve to a Repository with the name 'cockroachdb/cockroach'"] and data: { repository: null }. The same run had resolved the repo 79 times in the preceding 81 s and the same token synced it fine on the next run, so this was a transient GitHub glitch. githubGraphql returned body.data because { repository: null } is truthy, skipping the existing no-data retry, and the sync dereferenced the null repository.

Change

  • githubGraphql now treats a response that carries errors and whose root fields are all null as "no data": it goes through the existing 5-attempt backoff and then throws ProviderContractError instead of handing the sync a null root.
  • Responses with at least one resolved root field (for example batched nodes lists with some null entries) still pass through unchanged. FORBIDDEN still fails fast.
  • Tests for retry-then-succeed, retries exhausted, partial-data passthrough and forbidden fail-fast.

Impact of the incident

None on data: the unit was in shadow mode, was deferred one minute, re-ran and completed.

🤖 Generated with Claude Code

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 10:02
@cursor

cursor Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Central GitHub GraphQL client behavior changes for every sync that uses it; mitigated by narrow condition (errors + all-null roots) and new tests.

Overview
Fixes a case where GitHub GraphQL returned errors plus data whose root fields were all null (e.g. repository: null with NOT_FOUND). githubGraphql used to return that payload because body.data was truthy, which led sync code to dereference null.

The helper now uses hasResolvedRootField so it only returns early when there are no errors, or when at least one top-level field in data is non-null. Error responses with all-null roots follow the existing 5-attempt / 2s backoff “no data” path and end in ProviderContractError instead of partial null data. Partial responses (e.g. nodes with some null entries) and FORBIDDEN (still single attempt, no retry) are unchanged.

Adds gql.test.ts covering retry-then-success, exhausted retries, partial-data passthrough, and forbidden fail-fast.

Reviewed by Cursor Bugbot for commit 602609b. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused change matches the intended behavior, with regression coverage and no identified blocking issues.

0 open findings

What changed in this PR

Fixes transient GitHub GraphQL failures by routing error responses with all-null root fields through the existing retry logic.

Changes:

  • Retries all-null root responses instead of returning unusable data.
  • Preserves partial-data handling and forbidden-error behavior.
  • Adds four regression tests; tests were not executed.
File Description
services/​libs/​connectors/​src/​connectors/​github/​gql.ts Detects unresolved root fields before returning data.
services/​libs/​connectors/​src/​connectors/​github/​gql.test.ts Covers retry recovery, exhaustion, partial data, and forbidden errors.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mbani01
mbani01 merged commit b9110db into main Oct 16, 2026
14 checks passed
@mbani01
mbani01 deleted the fix/github-graphql-null-root-retry branch October 16, 2026 10:08
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