Skip to content

Send the CI run id with GraphQL requests - #316

Merged
Ayomi-gh merged 2 commits into
mainfrom
ayomi-gh/send-run-id-header
Nov 4, 2026
Merged

Ayomi-gh merged 2 commits into
mainfrom
ayomi-gh/send-run-id-header

Conversation

@Ayomi-gh

@Ayomi-gh Ayomi-gh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What

When GITHUB_RUN_ID is set, GraphQL requests now carry an X-Entitlements-Run-Id header with its value. Without the variable, nothing changes.

Why

entitlements-caches sits in front of GitHub for CI, but its logs only show the client IP, so we can't tell which CI run made a slow or missed request. With this header, the cache can log the run id (github/entitlements-caches companion PR).

Notes

  • Only GraphQL requests get the header. REST calls through Octokit don't go through the cache.
  • When the cache passes a request through, GitHub receives the header too, which has no effect.
  • Only the run id is sent, not the attempt number, because GITHUB_RUN_ATTEMPT isn't passed into the entitlements CI container.

Testing

bundle exec rspec spec/unit/entitlements/service/github_spec.rb spec/unit/entitlements/backend/github_team/service_spec.rb: 90 examples, 0 failures. rubocop is clean.

Adds an X-Entitlements-Run-Id header from GITHUB_RUN_ID, when set, so a
proxy such as entitlements-caches can tie its logs to a specific CI run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI auto review requested due to automatic review settings November 4, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped change includes unit coverage for both configured and unset GITHUB_RUN_ID cases, with no active review issues remaining.

No open issues 🎉

What changed in this PR

Adds optional CI run identification to GraphQL requests so entitlements-caches can associate requests with GitHub Actions runs, while preserving existing behavior when GITHUB_RUN_ID is unset.

Changes:

  • Adds the X-Entitlements-Run-Id header to GraphQL requests when GITHUB_RUN_ID is available.
  • Adds unit coverage for both configured and unset run-ID scenarios.
File Summary
lib/​entitlements/​service/​github.rb Conditionally attaches the CI run ID header to GraphQL requests. The new comment should be revised into a complete sentence.
spec/​unit/​entitlements/​service/​github_spec.rb Verifies header inclusion and omission behavior based on GITHUB_RUN_ID.

Review effort: Lite (auto)

@Ayomi-gh
Ayomi-gh merged commit f3e2632 into main Nov 4, 2026
13 checks passed
@Ayomi-gh
Ayomi-gh deleted the ayomi-gh/send-run-id-header branch November 4, 2026 16:55
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