Repository navigation
fix(gateway): reset staged headers on authority errors - #158669
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 1:36 AM ET / 05:36 UTC (Revision 2). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +13, Tests +46. Total +59 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
|
Merged via squash.
|
* 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 ...
* 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]>
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
* 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]>
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
e8bea93c1bafef106ef870da96b53b279b5d0a12.Data after Connection: closefailures 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.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.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.