Skip to content

fix(changelog): Add retry and robust error handling for GitHub GraphQL#701

Merged
BYK merged 5 commits intomasterfrom
seer/fix/changelog-graphql-retry
Jan 9, 2026
Merged

fix(changelog): Add retry and robust error handling for GitHub GraphQL#701
BYK merged 5 commits intomasterfrom
seer/fix/changelog-graphql-retry

Conversation

@seer-by-sentry
Copy link
Contributor

@seer-by-sentry seer-by-sentry bot commented Jan 9, 2026

Fixes CRAFT-8. The issue was that: GraphQL response lacks 'repository' due to 502, causing TypeError when accessed without validation.

  • Implement retry logic with exponential backoff for GitHub GraphQL queries.
  • Handle 5xx errors during GraphQL calls by retrying up to 3 times.
  • Validate GraphQL response structure and gracefully handle missing data.
  • Allow changelog generation to continue by marking failed commit data as null if a chunk's query fails after retries.

This fix was generated by Seer in Sentry, triggered by Burak Yigit Kaya. 👁️ Run ID: 8414569

Not quite right? Click here to continue debugging with Seer.

@seer-by-sentry seer-by-sentry bot requested a review from BYK January 9, 2026 19:53
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (changelog) Add retry and robust error handling for GitHub GraphQL by seer-by-sentry[bot] in #701

🤖 This preview updates automatically when you update the PR.

…ation

Fixes CRAFT-8

Remove redundant manual retry loop since @octokit/plugin-retry already
handles 5xx retries automatically (up to 3 times with exponential backoff).

The actual issue was missing response validation - GitHub GraphQL can return
HTTP 200 with missing/null repository field, causing TypeError when accessing
.repository properties.

Changes:
- Remove 37 lines of manual retry logic (duplicate of plugin behavior)
- Keep essential response validation with ?.repository check
- Maintain graceful error handling for all failure scenarios

This fixes three scenarios:
1. HTTP 502 errors: Handled by @octokit/plugin-retry
2. HTTP 200 with errors array: Caught by try-catch
3. HTTP 200 with missing repository: Caught by validation check
BYK added 2 commits January 9, 2026 22:23
Capture GraphQL changelog failures to Sentry with rich context for monitoring:
- Tag 'error_type' for easy filtering (graphql_changelog_failure)
- Tags for chunk_number and total_chunks for tracking failure patterns
- Context with chunk details, commit count, HTTP status, and error name

This enables:
- Tracking frequency of GraphQL failures in production
- Identifying patterns (e.g., specific chunks that fail consistently)
- Monitoring the effectiveness of the retry plugin
- Better visibility into GitHub API reliability issues

The error is still logged as a warning and handled gracefully (skipping
the failed chunk and continuing with remaining commits).
Add the full GraphQL query and additional metrics to Sentry error context:
- GraphQL query string (for reproducing issues)
- Query length (to identify if query size correlates with failures)
- Total hashes being processed (context for chunk failures)

This enables debugging questions like:
- Do larger queries fail more often?
- Are specific query patterns causing issues?
- Can we reproduce failures with the exact query?
Move GraphQL query into the main graphql_chunk context and remove the
redundant queryLength metric. The query string itself is more useful for
debugging, and totalHashes already provides the scale information needed.
@BYK BYK marked this pull request as ready for review January 9, 2026 22:29
@BYK BYK enabled auto-merge (squash) January 9, 2026 22:29
@BYK BYK merged commit 744e601 into master Jan 9, 2026
16 checks passed
@BYK BYK deleted the seer/fix/changelog-graphql-retry branch January 9, 2026 22:30
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.

1 participant