Skip to content

fix(gateway): reset staged headers on authority errors - #158669

Merged
steipete merged 1 commit into
mainfrom
codex/http-error-response-headers-20260926
Sep 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/http-error-response-headers-20260926

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157501

What Problem This Solves

Fixes: losing HTTP authority after a handler stages a response can give clients a parsing error instead of the intended 401 or 403. The abandoned response's length, encoding, cache headers, and status text can survive into the error response.

User Impact

Clients receive a complete, uncached denial response with the correct status text. Security and CORS headers remain intact, and partially written responses close safely.

Why This Change Was Made

The original authority-outcome fix is already merged. This follow-up shares the existing error-response preparation between the 401, operator-denial 403, and 500 writers, and removes the classifier's duplicate terminal-response branch. Authority checks and cookie/grant policy stay with their existing owners.

The existing TCP cases now stage a one-byte length, gzip encoding, download metadata, and cache headers before authority changes. They check the resulting wire response on both core and registered plugin routes. An existing runtime-scope case also retains the admitted grant's cancellation signal assertion. No new cases, servers, sleeps, or test-only production seams are added.

Evidence

  • Fresh independent review through P2, formatting, and whitespace checks pass for this five-file follow-up on e8bea93c1bafef106ef870da96b53b279b5d0a12.
  • The earlier prepared implementation reproduced four real Data after Connection: close failures when the header repair was removed; eight controls passed. With the repair, 12 TCP cases, 28 runtime-scope cases, and 249 sibling cases passed, along with the selected changed-source checks.
  • That remote proof used base 140b6026c7cb7d038266c468292ff32a6105c3e1. All five follow-up file postimages are identical to the tested implementation, but other current-main inputs changed, so it is not presented as current-head integration proof.
  • Measured earlier-context single-worker file costs: authority outcomes 22.776 s; runtime scopes 29.946 s. These include roughly 10.8 s of worker preparation per invocation. Per-file CI timings were not exposed in the bounded workflow log lookup; the exact-head CI gate passed.

Current-head CI 36220697651 passed at 2faac567eb00f8d0ee112c9d05c20408e9910ba6, including the enforced CI gate. The completed ClawSweeper review found no actionable defects; native review and preparation passed for that same head.

Discard abandoned representation headers before sending a complete 401 or
operator-denial 403 response. Share the existing 500 preparation and terminal
response handling, preserving security/CORS headers and cookie policy.

Extend the existing core/plugin TCP cases with staged response metadata and
retain the admitted runtime-scope cancellation signal assertion.

Related: #157501
@steipete steipete self-assigned this Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 1:36 AM ET / 05:36 UTC (Revision 2).

ClawSweeper review

What this changes

The Gateway HTTP error writers clear staged payload headers and reset status text before sending denial responses, with expanded TCP assertions for core and plugin routes.

Merge readiness

✅ Ready for maintainer review

Current main still leaves staged response headers on 401 and operator-denial 403 replies. The earlier merged authority-outcome change did not fix that distinct gap, so this PR remains useful. The introduced patch has no supported blocking correctness finding.

Priority: P2
Reviewed head: 2faac567eb00f8d0ee112c9d05c20408e9910ba6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused shared-owner repair with relevant TCP boundary evidence and no supported patch defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body reports four pre-fix framing failures and 12 after-fix TCP cases using a real HTTP client against the Gateway's core and plugin handlers; the test source captures the changed status, headers, and body after injected authority changes. The reported run used an earlier base, while current-head integration remains with ordinary CI. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports four pre-fix framing failures and 12 after-fix TCP cases using a real HTTP client against the Gateway's core and plugin handlers; the test source captures the changed status, headers, and body after injected authority changes. The reported run used an earlier base, while current-head integration remains with ordinary CI. No stored-data contract changes.
Evidence reviewed 7 items Current main 401 gap: The current-main 401 writer clears cookies but does not discard staged length, encoding, or cache metadata before ending the response.
Current main 403 gap: The operator-denial writer sends JSON directly, so staged representation headers remain on an unsent response.
Introduced response repair: The pinned PR delta reuses the existing representation-header cleanup, removes staged Content-Length, sets no-store and the error status text, and closes an already committed response.
Findings None None.
Security None None.

How this fits together

The Gateway serves HTTP requests through core and plugin handlers. After asynchronous work, a response-bound authority check may reject a request, and shared response helpers write the denial or close a partial response.

flowchart LR
  A[HTTP client] --> B[Core or plugin route]
  B --> C[Awaited handler work]
  C --> D[Current authority check]
  D --> E[Error response preparation]
  E --> F[Denial response or closed connection]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +13, Tests +46. Total +59 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 33 20 +13
Tests 2 49 3 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 82 23 +59

Review metrics

Metric Value Why it matters
Production and test delta production +33/−20 (net +13); tests +49/−3 (net +46) The small production increase shares error-response preparation; most growth strengthens existing TCP assertions.

Root-cause cluster

Relationship: canonical
Canonical: #158669
Summary: The earlier merged change settled authority failures; this follow-up addresses response metadata left staged after those failures.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Gateway 401, operator-denial 403, and unexpected-error 500 responses should discard abandoned payload metadata while preserving security and CORS headers; committed partial responses should close.

Do we have a high-confidence way to reproduce the issue?

Yes. The current-main writers visibly retain staged headers when authority changes after handler work, and the TCP suite provides a concrete path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The patch uses the existing representation-header cleanup at the shared response boundary and leaves authority and grant decisions with their current owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d6dc69c02dfb.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Malformed denial replies affect a bounded Gateway HTTP authority-expiry path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body reports four pre-fix framing failures and 12 after-fix TCP cases using a real HTTP client against the Gateway's core and plugin handlers; the test source captures the changed status, headers, and body after injected authority changes. The reported run used an earlier base, while current-head integration remains with ordinary CI. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports four pre-fix framing failures and 12 after-fix TCP cases using a real HTTP client against the Gateway's core and plugin handlers; the test source captures the changed status, headers, and body after injected authority changes. The reported run used an earlier base, while current-head integration remains with ordinary CI. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-26T05:22:46.184Z sha 2faac56 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 26, 2026 05:24
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 2faac567eb00f8d0ee112c9d05c20408e9910ba6
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/http-request-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@steipete
steipete merged commit 02192bc into main Sep 26, 2026
284 of 285 checks passed
@steipete
steipete deleted the codex/http-error-response-headers-20260926 branch September 26, 2026 06:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 26, 2026
* commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits)
  fix(gateway): preserve typed boxed-number coercion
  chore(ui): refresh control ui locales (#158689)
  fix(gateway): reset staged headers on authority errors (#158669)
  fix(workers): keep inbound staging stable during quota scans
  fix: preserve Telegram delivery after bot identity changes (#158612)
  fix(ui): keep automation starter prompts out of startup (#158482)
  fix(cli): distinguish configuration read failures from invalid input (#158671)
  test: remove retired progress coercion suppression allowance
  refactor(gateway): schedule worker placement maintenance (#158662)
  fix(daemon): keep native service checks within their timeout (#154565)
  fix(test): restore gateway steering fixture contracts (#158478)
  fix(acpx): use SDK filesystem publication boundary
  fix(agentsapi): load OpenClaw persona and workspace context (#158328)
  fix(gateway): drop progress snapshot coercion suppression
  fix(qa): accept native Codex truncation in cache evidence (#158454)
  fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633)
  perf(gateway): release event payloads from live text guards (#158643)
  perf(sessions): reduce stalls when saving large chat messages (#158402)
  fix(qa): reject history-bearing utility requests without session affinity (#158496)
  test: allow intentional progress snapshot coercion
  ...
vincentkoc added a commit that referenced this pull request Sep 26, 2026
* fix(test): verify followup completion ordering

Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults.

* fix(test): verify followup completion ordering

* chore: retain followup test branch ancestry

The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update.

* commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8':
  fix(test): verify followup completion ordering

* test(auto-reply): signal queued presentation entry

* chore: refresh followup test on boundary fix

* commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits)
  fix(gateway): preserve typed boxed-number coercion
  chore(ui): refresh control ui locales (#158689)
  fix(gateway): reset staged headers on authority errors (#158669)
  fix(workers): keep inbound staging stable during quota scans
  fix: preserve Telegram delivery after bot identity changes (#158612)
  fix(ui): keep automation starter prompts out of startup (#158482)
  fix(cli): distinguish configuration read failures from invalid input (#158671)
  test: remove retired progress coercion suppression allowance
  refactor(gateway): schedule worker placement maintenance (#158662)
  fix(daemon): keep native service checks within their timeout (#154565)
  fix(test): restore gateway steering fixture contracts (#158478)
  fix(acpx): use SDK filesystem publication boundary
  fix(agentsapi): load OpenClaw persona and workspace context (#158328)
  fix(gateway): drop progress snapshot coercion suppression
  fix(qa): accept native Codex truncation in cache evidence (#158454)
  fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633)
  perf(gateway): release event payloads from live text guards (#158643)
  perf(sessions): reduce stalls when saving large chat messages (#158402)
  fix(qa): reject history-bearing utility requests without session affinity (#158496)
  test: allow intentional progress snapshot coercion
  ...

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Discard abandoned representation headers before sending a complete 401 or
operator-denial 403 response. Share the existing 500 preparation and terminal
response handling, preserving security/CORS headers and cookie policy.

Extend the existing core/plugin TCP cases with staged response metadata and
retain the admitted runtime-scope cancellation signal assertion.

Related: openclaw#157501
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
* fix(test): verify followup completion ordering

Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults.

* fix(test): verify followup completion ordering

* chore: retain followup test branch ancestry

The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update.

* commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8':
  fix(test): verify followup completion ordering

* test(auto-reply): signal queued presentation entry

* chore: refresh followup test on boundary fix

* commit '622be54be3ffe0fce27d6a4b147c76d4b19c528c': (70 commits)
  fix(gateway): preserve typed boxed-number coercion
  chore(ui): refresh control ui locales (openclaw#158689)
  fix(gateway): reset staged headers on authority errors (openclaw#158669)
  fix(workers): keep inbound staging stable during quota scans
  fix: preserve Telegram delivery after bot identity changes (openclaw#158612)
  fix(ui): keep automation starter prompts out of startup (openclaw#158482)
  fix(cli): distinguish configuration read failures from invalid input (openclaw#158671)
  test: remove retired progress coercion suppression allowance
  refactor(gateway): schedule worker placement maintenance (openclaw#158662)
  fix(daemon): keep native service checks within their timeout (openclaw#154565)
  fix(test): restore gateway steering fixture contracts (openclaw#158478)
  fix(acpx): use SDK filesystem publication boundary
  fix(agentsapi): load OpenClaw persona and workspace context (openclaw#158328)
  fix(gateway): drop progress snapshot coercion suppression
  fix(qa): accept native Codex truncation in cache evidence (openclaw#158454)
  fix(gateway): keep chat subscriptions stable during unrelated approvals (openclaw#158633)
  perf(gateway): release event payloads from live text guards (openclaw#158643)
  perf(sessions): reduce stalls when saving large chat messages (openclaw#158402)
  fix(qa): reject history-bearing utility requests without session affinity (openclaw#158496)
  test: allow intentional progress snapshot coercion
  ...

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant