Repository navigation
fix: propagate trace context and job identity to backend services - #79351
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ Matt Pocock Skills ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
Reviewed the changed lines. I found no actionable correctness, performance, or maintainability issues. The grumpy-coder specialist pass was unavailable because its file reads were denied; this verdict is based on the independent static review of the prefetched diff and targeted source context. No tests were run per the static-review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
Comment MemoryPeek at saved memory (review-history)History |
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design and /diagnosing-bugs. No confirmed correctness bugs. The main risks are rollout ordering and auth-path coupling. Test suites were not run in this environment because vitest is not installed.
📋 Key Themes & Highlights
Key Themes
- Auth-path coupling: three auth modules now load the full telemetry module (about 86 extra transitive modules). See the
token_broker.cjscomment. - Rollout compatibility: the gateway admission response check requires exact key echo, so
job_idmust be supported by the gateway before the client ships. - Diagnostics gating auth: an unguarded
encodeURIComponentonGITHUB_JOBcan turn diagnostic metadata into an authorization failure. Likelihood is low. - Spec wording:
admission-service-specification.md(around line 275) still says "the same ten identity fields" whilejob_idis optional. Clarify that it is an optional eleventh diagnostic member. - Test gaps: traceparent is asserted only on retry attempts 1 and 2. Consider asserting baggage on every retry, and add a test for a malformed
GITHUB_JOB.
Positive Highlights
- ✅ Headers are deliberately withheld from the OIDC issuer, which keeps diagnostics out of the trust boundary.
- ✅
buildServiceRequestHeadersvalidates trace and span IDs before emittingtraceparent. - ✅ Gateway and safe-output responses bind the request keys, so diagnostic fields cannot be silently swapped.
- ✅ Tests cover the baggage encoding, including
/and space inGITHUB_JOB.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| "use strict"; | ||
|
|
||
| const { readBoundedBody } = require("./admission_protocol.cjs"); | ||
| const { buildServiceRequestHeaders } = require("./send_otlp_span.cjs"); |
There was a problem hiding this comment.
[/codebase-design] The auth path now imports the whole telemetry module just for header helpers. token_broker.cjs, check_gateway_admission.cjs, and safe_output_authorization.cjs each require send_otlp_span.cjs (about 3,100 lines), which adds roughly 86 transitive modules to token exchange, gateway admission, and safe-output authorization.
💡 Suggested refactor
Move buildServiceRequestHeaders, buildTraceparent, isValidTraceId, and isValidSpanId into a small module such as service_correlation.cjs. send_otlp_span.cjs can re-export them, and the three auth-path callers can import the small module instead. This keeps the auth load surface minimal and makes the diagnostic-only contract explicit.
@copilot please address this.
There was a problem hiding this comment.
Moved the correlation helpers into service_correlation.cjs; the three backend callers now load that small module, and send_otlp_span.cjs re-exports the existing helpers. Commit: ac48bff.
| if (typeof idToken === "string" && idToken) actionsCore.setSecret(idToken); | ||
| const claims = oidcClaims(idToken, audience, binding); | ||
| const request = { schema_version: 1, ...binding, check_run_id: claims.check_run_id }; | ||
| const request = { schema_version: 1, ...binding, check_run_id: claims.check_run_id, ...(jobId ? { job_id: jobId } : {}) }; |
There was a problem hiding this comment.
[/codebase-design] Rollout coupling: job_id is now sent to the gateway admission endpoint, and the response check (lines 185-186) rejects any response whose key set differs from the request keys plus allowed. A gateway that does not echo job_id will reject every admission.
💡 Suggested change
Confirm that the gateway supports echoing job_id before this client ships, and document the required deploy order in the webhook gateway spec. If the rollout cannot be ordered, gate sending job_id on the backend advertising support.
@copilot please address this.
There was a problem hiding this comment.
Documented that receiver support for accepting and exactly echoing optional job_id must be deployed and verified before publishing or activating a client revision that sends it. External receiver readiness remains an integration responsibility. Commit: ac48bff.
| /** @type {Record<string, string>} */ | ||
| const headers = {}; | ||
| if (isValidTraceId(traceId) && isValidSpanId(spanId)) headers.traceparent = buildTraceparent(traceId, spanId); | ||
| if (env.GITHUB_JOB) headers.baggage = `${OTEL_ATTR_CICD_PIPELINE_TASK_NAME}=${encodeURIComponent(env.GITHUB_JOB)}`; |
There was a problem hiding this comment.
[/diagnosing-bugs] encodeURIComponent throws URIError on lone surrogates, and this call is unguarded. In safe_output_authorization.cjs, job_id is serialized through canonical(), which fails closed with invalid_preparation, so diagnostic metadata can block safe-output authorization. Likelihood is low because GitHub job IDs are ASCII, but diagnostics should never gate auth.
💡 Suggested fix
Omit baggage and the job_id body member when GITHUB_JOB is not well-formed Unicode. Add a regression test with a malformed GITHUB_JOB that asserts authorization still proceeds without the diagnostic fields.
@copilot please address this.
There was a problem hiding this comment.
Malformed Unicode job IDs now omit both baggage and the authorization request's job_id, without blocking authorization; a regression test covers this. Commit: ac48bff.
There was a problem hiding this comment.
🟡 Changes recommended
The documentation still permits discarding new job-correlation baggage and incorrectly attributes fallback traces and per-attempt spans to gateway admission.
1 open issue
What changed in this PR
Propagates workflow trace context and diagnostic job identity from gh-aw runtime clients to backend services, while keeping correlation headers separate from GitHub OIDC requests.
Changes:
- Adds shared
traceparentand job-baggage header generation. - Includes JSON
job_idin backend payloads without changing safe-output invocation digests. - Expands correlation tests and updates protocol specifications.
| File | Description |
|---|---|
specs/otel-observability-spec.md |
Defines backend trace and job-correlation requirements. |
docs/src/content/docs/specs/webhook-gateway-specification.md |
Documents diagnostic gateway job_id. |
docs/src/content/docs/specs/token-broker-specification.md |
Updates exchange and invalidation schemas. |
docs/src/content/docs/specs/admission-service-specification.md |
Documents admission and conclusion job metadata. |
actions/setup/js/token_broker.test.cjs |
Tests correlation headers, payloads, and OIDC isolation. |
actions/setup/js/token_broker.cjs |
Adds correlation to exchanges and invalidation. |
actions/setup/js/send_otlp_span.test.cjs |
Tests header encoding and invalid-context handling. |
actions/setup/js/send_otlp_span.cjs |
Exports the shared correlation-header helper. |
actions/setup/js/safe_output_authorization.test.cjs |
Tests authorization correlation and OIDC isolation. |
actions/setup/js/safe_output_authorization.cjs |
Adds headers and top-level job metadata. |
actions/setup/js/conclusion_admission.test.cjs |
Tests conclusion trace and job propagation. |
actions/setup/js/check_gateway_admission.test.cjs |
Tests correlation and job-response binding. |
actions/setup/js/check_gateway_admission.cjs |
Adds gateway headers and job metadata. |
actions/setup/js/check_admission.test.cjs |
Tests stable job identity and distinct retry spans. |
actions/setup/js/check_admission.cjs |
Uses shared headers while preserving attempt spans. |
actions/setup/js/admission_protocol.test.cjs |
Tests job-ID encoding, omission, and validation. |
actions/setup/js/admission_protocol.cjs |
Adds optional job_id to admission identity. |
Review effort: Max (adaptive)
| "workflow_call_id": "1234-2:acme/project/.github/workflows/triage.lock.yml@refs/heads/main", | ||
| "run_id": "1234", | ||
| "run_attempt": "2", | ||
| "job_id": "activation", |
There was a problem hiding this comment.
Clarified that proxies preserve only the locally generated task baggage member and that invalid baggage is ignored without affecting admission. The conclusion example already includes job_id. Commit: ac48bff.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "e5058f3304f575438b000beb0da3f062668653df",
"kind": "requested",
"schema_version": "1",
"state": "76731c76d76ce6443b058cf8522387b614c45917bb8bc8cb7d620f32aa7215df",
"work": [
"0cf81f852cdeff8b557989cc1a03f5b88d45ed61fbec4f53ff322eb43380db7f",
"52eef9281e30cf14d835eea84f9900e800c6bb1386a473e54a222bc5a52f5aa7",
"5a83e59e6238364cc898a8d42e6ebdaa7d0586946cf12d09f99ad030982b1c15",
"b5fe49246214ddf644f03d98b33986762e268f267a785fdf4e763b4205642e21"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Summary
Backend token-broker, admission, and authorization requests need the workflow's trace context and job identity so the backend can correlate requests with workflow execution.
traceparentfrom the current gh-aw OTEL context, preserving admission's distinct request-attempt spans.job_idfromGITHUB_JOBin token exchanges and invalidation, admission and conclusion delivery, gateway admission, and safe-output authorization. Preserve the original value using JSON string encoding.baggagewith OpenTelemetry'scicd.pipeline.task.namekey for distributed job correlation.Job identity is diagnostic metadata, not proof of authorization. Arbitrary incoming baggage and exporter credentials are not forwarded, and correlation headers are not sent to the GitHub OIDC issuer. Backend instrumentation must explicitly record extracted baggage as span attributes if desired.
Compatibility
Closed backend request schemas must allow the new
job_idstring; gateway admission must echo it unchanged. Callers without job context omit the member. Safe-output invocation digests and logical identities are unchanged. The related protocol specifications document these requirements.Validation
make agent-report-progresspassed, including JavaScript typechecking, changed-file lint, CLI build, and all 1,053 tests across seven affected suites. Tests cover payload job IDs, trace propagation, stable job identity across retries, encoding, invalid/missing context, gateway response binding, and isolation from OIDC issuance.