Skip to content

fix(httptransport): classify remaining client cancellations - #5251

Merged
GAlexIHU merged 2 commits into
mainfrom
codex/http-cancellation-classification
Oct 6, 2026
Merged

GAlexIHU merged 2 commits into
mainfrom
codex/http-cancellation-classification

Conversation

@GAlexIHU

@GAlexIHU GAlexIHU commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Wrapped gRPC cancellations can still produce HTTP 500 and ERROR diagnostics after the caller cancels its request. Legacy problem responses also override statuses by matching context canceled in error text. This completes the shared classification introduced in #5236.

  • Recognize typed Go and gRPC cancellation causes, including wrapped and joined errors. Record an empty 499 only when the request context is canceled too.
  • Apply the same rule to transport errors, legacy problems, and direct v3 error responses. Preserve the supplied status for internal cancellations, deadlines, and unrelated failures.
  • Preserve the context cause when database/sql automatically rolls back before Commit, while retaining sql.ErrTxDone.
  • Distinguish response connection write failures from serialization failures. Log canceled writes as warnings without rewriting committed headers, including untyped HTTP/2 stream errors. Server write timeouts remain errors even when the HTTP server also cancels the request context.

e2e/httperrors covers the shared contract through real HTTP/1 TCP half-closes, HTTP/2 resets, gRPC calls, and PostgreSQL automatic rollback. Controlled test handlers exercise all changed paths without production fault-injection endpoints. The suite runs under the race detector as part of make -C e2e test-base; make -C e2e test-http-errors runs it independently.

Validation:

  • All 78 e2e scenarios passed with the race detector. Against the pre-change implementations, 46 scenarios failed across cancellation responses, legacy status preservation, diagnostics, response writes, and SQL rollback.
  • Focused root-module race tests, transport lint, complete e2e lint, and e2e vet passed.
  • Both default and credits-disabled e2e packages compile in readonly module mode. Collector command dependencies resolve in readonly mode.
  • Updated e2e and collector dependency metadata for the shared helper's expanded imports.

RetriggerConfidence Score: 5/5

The changes since the previous review appear safe to merge.

Summary

The PR extends cancellation classification across HTTP transport, legacy problems, and v3 errors, and adds connection-level and transaction tests. Since the previous review, it also adds an e2e error-handling suite and distinguishes server write timeouts from canceled response writes.

  • No actionable new issue was established in the changes since the previous review.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Request or response failure] --> B{Request context canceled?}
  B -- No --> E[Preserve error status and diagnostics]
  B -- Yes --> C{Typed cancellation cause?}
  C -- Yes --> D[Record empty 499]
  C -- No --> F{Response write failed?}
  F -- No --> E
  F -- Yes --> G{Network timeout?}
  G -- Yes --> E
  G -- No --> H[Preserve committed status; warn]
Loading

Reviews (2) · Last reviewed commit: "test(httptransport): cover cancellation ..."

@GAlexIHU GAlexIHU added the release-note/bug-fix Release note: Bug Fixes label Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: openmeterio/openmeter/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c19902d-ca71-48f9-865c-fca490af8e9d
📥 Commits

Reviewing files that changed from the base of the PR and between 0dce489 and b565a04.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • e2e/go.mod is excluded by !**/*.mod
  • e2e/go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (24)
  • AGENTS.md
  • api/v3/apierrors/cancellation_test.go
  • api/v3/apierrors/errors.go
  • e2e/Makefile
  • e2e/README.md
  • e2e/httperrors/cancellation_test.go
  • e2e/httperrors/encoding_test.go
  • e2e/httperrors/harness_test.go
  • e2e/httperrors/response_test.go
  • e2e/httperrors/transaction_test.go
  • pkg/contextx/cancellation.go
  • pkg/contextx/cancellation_test.go
  • pkg/errorsx/handler.go
  • pkg/errorsx/handler_test.go
  • pkg/framework/README.md
  • pkg/framework/commonhttp/encoder.go
  • pkg/framework/transaction/cancellation_test.go
  • pkg/framework/transaction/transaction.go
  • pkg/framework/transport/httptransport/cancellation_test.go
  • pkg/framework/transport/httptransport/encoder/encoder.go
  • pkg/framework/transport/httptransport/handler.go
  • pkg/framework/transport/httptransport/handler_test.go
  • pkg/models/problem.go
  • pkg/models/problem_test.go
 _______________________________________________
< Don't count your bugs before they're patched. >
 -----------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip turip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@GAlexIHU
GAlexIHU marked this pull request as ready for review October 6, 2026 11:27
@GAlexIHU
GAlexIHU requested a review from a team as a code owner October 6, 2026 11:27
@GAlexIHU
GAlexIHU merged commit 9cb8114 into main Oct 6, 2026
@GAlexIHU
GAlexIHU deleted the codex/http-cancellation-classification branch October 6, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants