Skip to content

WIP: capture and display trace IDs in API error output#185

Open
afinetooth wants to merge 1 commit into
masterfrom
trace-id-error-diagnostics
Open

WIP: capture and display trace IDs in API error output#185
afinetooth wants to merge 1 commit into
masterfrom
trace-id-error-diagnostics

Conversation

@afinetooth
Copy link
Copy Markdown
Member

Summary

Adds tracing-header diagnostics to API error output so users (and Coveralls support) can correlate failed requests with CDN/server logs.

Status: WIP — code complete, no specs yet.

What changes

  • Api::HTTPError now exposes headers : HTTP::Headers (the full response headers from the failing response).
  • Api::HTTPError#trace_id returns the first match among common tracing headers: cf-ray, x-request-id, x-amzn-requestid, x-amzn-trace-id, x-trace-id. Returns nil if none are present.
  • The CLI rescues for Api::InternalServerError, Api::UnprocessableEntity, and the generic Api::HTTPError now print a Trace ID: … line (when one exists) alongside the existing diagnostic block, so users can include it when contacting Coveralls support.

No behavior change for happy-path requests. Pure diagnostic enhancement on the error path.

What's left to ship

  • Add specs for Api::HTTPError#trace_id covering each header name + the nil case.
  • Add a CLI-level spec that an error response containing a tracing header is rendered into the user-visible output.
  • (Optional) Confirm with the Coveralls server team which tracing header(s) are most reliably present in production responses, and reorder the probe accordingly.
  • Cosmetic: when no trace_id is present, the heredoc emits a blank line. Decide whether to suppress it.

For the next Claude Code session

This repo has the superpowers plugin available globally. Recommended flow:

  1. superpowers:writing-plans — scope the spec additions and any cosmetic cleanup explicitly.
  2. superpowers:test-driven-development — write the failing specs first, then rerun the suite.
  3. superpowers:verification-before-completionmake test and make build before requesting review.
  4. superpowers:requesting-code-review — when the checklist above is empty.

Test plan

  • make test passes after specs are added.
  • make build produces a binary that surfaces a Trace ID: line when the server returns a 500 with a cf-ray header (manual smoke test against a mock server is sufficient).

🤖 Generated with Claude Code

Adds a `headers` getter and `trace_id` helper to Api::HTTPError. The
helper probes common CDN/cloud tracing headers (cf-ray, x-request-id,
x-amzn-requestid, x-amzn-trace-id, x-trace-id) and returns the first
match. The CLI's error rescues for InternalServerError, UnprocessableEntity
and the generic HTTPError now print "Trace ID: ..." alongside the
existing status/response so users can include it when contacting support.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coveralls-official
Copy link
Copy Markdown

Coverage Report for CI Build 25443965755

Coverage increased (+0.06%) to 94.129%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: 11 of 11 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1005
Covered Lines: 946
Line Coverage: 94.13%
Coverage Strength: 2.15 hits per line

💛 - Coveralls

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