fix(#2779): respect inbound TRACEPARENT in trace chain - #2960
Conversation
E2E tests did not runE2E tests run automatically for org/repo members and collaborators on pull requests. For other contributors, a maintainer must add the See E2E testing guide for details. |
PR Summary by QodoRespect inbound TRACEPARENT across the run’s trace chain
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Site previewPreview: https://2efd4163-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Code Review by Qodo
Context used✅ Tickets:
🎫 Respect a pre-existing TRACEPARENT in the security trace chain 🎫 feat: implement Level 2 distributed tracing — OTLP export to a backend✅ Compliance rules (platform):
54 rules✅ Skills:
writing-user-docs, writing-adrs 1.
|
7c72773 to
45c25ee
Compare
Add ParseTraceParent, TraceParentWithFlags, and UUIDFromTraceID so an inbound traceparent can be validated, its trace-id adopted as the run's security trace id, and its trace-flags (the W3C sampled bit) carried forward instead of being rewritten to sampled. Parsing is forward-compatible per the W3C spec: version 00 requires exactly four fields, unknown versions tolerate trailing fields, and version ff, all-zero ids, and uppercase hex are rejected. Signed-off-by: Dharit Shah <dhshah@redhat.com>
A trace id adopted from an inbound W3C traceparent is dashed hex but not necessarily UUID v4, so the strict v4 validator would reject it. Add IsShellSafeTraceID, which checks the property that actually matters for shell interpolation — lowercase hex and dashes in UUID shape — without the version/variant requirement. Signed-off-by: Dharit Shah <dhshah@redhat.com>
When a parent process exports TRACEPARENT (nested or instrumented invocation), fullsend now continues that trace instead of starting its own: the inbound trace-id becomes the unified security/W3C trace id, the inbound span-id is recorded as the root span's remote parent, and the inbound trace-flags are preserved through child-script TRACEPARENT, the recorder, and run-summary.json (previously hardcoded to sampled). childScriptEnv now filters any TRACEPARENT already present — inherited from the process environment or set in runner_env — so exactly one entry, fullsend's own, is seen by child scripts; env lookups resolve the first match, so a stale value used to shadow it. TRACESTATE passes through untouched. The shell-safety call sites switch to IsShellSafeTraceID since adopted ids are not UUID v4. The adoption logic lives in resolveTraceIdentity, a pure helper, so the behavior is unit-testable outside runAgent. Supersedes and ports fullsend-ai#2833 (closed unmerged for process reasons), adding the remote-parent record, summary flag fidelity, and W3C forward-compatible version parsing that the original missed. Signed-off-by: Dharit Shah <dhshah@redhat.com>
45c25ee to
db1dff4
Compare
|
🤖 Finished Retro · ✅ Success · Started 11:28 AM UTC · Completed 11:34 AM UTC |
|
PR #2960 (respect inbound TRACEPARENT in trace chain) had a well-functioning review workflow. The Qodo review agent found a real correctness bug — TRACEPARENT shadowing from runnerEnv in childScriptEnv() — which the author fixed within 4 minutes with new tests. The human reviewer (rh-hemartin) approved with no additional findings, meaning the agent fully covered review quality on this PR. One recurring gap persists: the PR touches internal/cli/ which AGENTS.md documents as requiring e2e tests, but e2e tests did not run (contributor needed ok-to-test label) and neither agent nor human flagged this. This exact gap is already tracked in issue #2036. No new proposals are warranted — the workflow was efficient (1 review iteration, ~17h to merge including overnight wait), and the single data point of agent success is not yet enough to justify autonomy changes. |
Closes #2779.
Re-land of #2833, which was closed unmerged for process reasons (unintended auto-code), not substance. The adoption logic now lives in an extracted pure helper (
resolveTraceIdentity) so it is unit-tested outsiderunAgent— addressing the patch-coverage gap that #2833 hit.What changed
TRACEPARENTis adopted: its trace-id becomes the unified security/W3C trace id, a fresh root span continues the parent trace, and the W3Ctrace-flags(sampled bit) are preserved end-to-end. Invalid or absent values fall back to fresh Level 1 identity generation.childScriptEnvfilters any inheritedTRACEPARENTbefore appending fullsend's own — env lookups resolve the first match, so the stale parent value used to shadow it.TRACESTATEpasses through untouched.injectTraceID/buildScanContextCommandswitches toIsShellSafeTraceID(lowercase hex + dashes in UUID shape): adopted trace ids are not UUID v4, and the charset is what shell interpolation safety depends on.Beyond #2833
run-summary.json'straceparentandRecorder.TraceParent()carry the real flags (previously hardcoded-01, which would re-advertise an upstream-unsampled trace as sampled).ParseTraceParentis W3C forward-compatible: version00requires exactly four fields, unknown versions tolerate trailing fields,ff/all-zero ids/uppercase are rejected.Trust note
An upstream process can now choose the run's security trace id via
TRACEPARENT. This affects audit correlation, not audit integrity (the finding hash chain covers content, not id uniqueness), andTRACEPARENTarrives from the same trust domain as the rest of the workflow env.fullsend.work_item_idremains the primary cross-run correlation key per ADR 0050.Testing
resolveTraceIdentity,childScriptEnv,ParseTraceParent,TraceParentWithFlags,UUIDFromTraceID,IsShellSafeTraceID, recorderNew/TraceParent/Finalize).go test -racegreen forinternal/telemetry,internal/security,internal/cli;gofmt/go vet/pre-commit clean.