Skip to content

fix(shared): reject HTTP status codes outside the 100-599 range#110554

Merged
steipete merged 2 commits into
openclaw:mainfrom
tzy-17:fix/assistant-error-format-http-status-range
Jul 18, 2026
Merged

fix(shared): reject HTTP status codes outside the 100-599 range#110554
steipete merged 2 commits into
openclaw:mainfrom
tzy-17:fix/assistant-error-format-http-status-range

Conversation

@tzy-17

@tzy-17 tzy-17 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

extractHttpStatusMatch in src/shared/assistant-error-format.ts only checked Number.isFinite(code), so 3-digit sequences such as "000", "099", "600", and "999" were accepted as valid HTTP statuses. Downstream code then:

  1. Surfaced them as "HTTP 0" or "HTTP 999" in user-visible messages via formatRawAssistantErrorForUi.
  2. Fed them into retry/classification branches (e.g. isCloudflareOrHtmlErrorPage checks code < 500 and code < 600, so code: 0 would pass both predicates and skip the Cloudflare code list).

The regex \\d{3} accepts any 3-digit number, but only 100-599 are valid HTTP status codes per RFC 9110.

Fix

Add range validation code >= 100 && code <= 599 to extractHttpStatusMatch. Both extractLeadingHttpStatus and extractProviderWrappedHttpStatus benefit since they share this helper.

 function extractHttpStatusMatch(
   match: RegExpMatchArray | null,
 ): { code: number; rest: string } | null {
     return null;
   }
   const code = Number(match[1]);
     return null;
   }
   return { code, rest: (match[2] ?? "").trim() };
 }

Evidence

New test file src/shared/assistant-error-format.test.ts covers both helpers:

src/shared/assistant-error-format.test.ts
  extractLeadingHttpStatus
    ✓ accepts status codes in the valid HTTP range 100-599
    ✓ rejects 3-digit sequences outside the HTTP status code range
    ✓ rejects strings that do not start with a 3-digit HTTP status
  extractProviderWrappedHttpStatus
    ✓ accepts provider-wrapped statuses inside the valid HTTP range
    ✓ rejects provider-wrapped statuses outside the valid HTTP range

Test Files  1 passed (1)
Tests  5 passed (5)

Regression check on extensions/ollama/src/stream-runtime.test.ts (which uses extractLeadingHttpStatus for failover/retry logic):

Test Files  1 passed (1)
Tests  105 passed (105)
Duration  50.45s

All existing tests pass, confirming valid HTTP statuses (503, 429, 500, etc.) are still correctly extracted.

Co-authored-by: Patrick Erichsen [email protected]

extractHttpStatusMatch only checked Number.isFinite, so 3-digit
sequences such as "000", "099", "600", and "999" were accepted as
valid HTTP statuses. Downstream code then surfaced them as "HTTP 0"
in user-visible messages and fed them into retry/classification
branches (e.g. isCloudflareOrHtmlErrorPage checks `code < 500` and
`code < 600`). Restrict the extracted code to the IANA HTTP status
code range (100-599).

Co-authored-by: Patrick Erichsen <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 5:35 AM ET / 09:35 UTC.

Summary
The PR rejects extracted three-digit HTTP status prefixes outside 100–599 and adds focused coverage for shared error-format parsing.

PR surface: Source -2, Tests +87. Total +85 across 2 files.

Reproducibility: yes. from source inspection: a three-digit prefix such as 000, 099, 600, or 999 reached HTTP parsing before this branch’s shared range check; no current-main runtime reproduction was independently established here.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted terminal or runtime-log transcript showing invalid leading and provider-wrapped prefixes do not produce HTTP labels or parsed codes.
  • Refresh the branch against current main and retain focused coverage for valid and invalid boundary values.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body reports focused test output, but it lacks redacted after-fix terminal, live-output, or runtime-log evidence showing invalid plain-text and provider-wrapped prefixes no longer receive HTTP treatment; add that proof to the PR body and request a re-review if needed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The supplied evidence is unit and regression-test output only; it does not demonstrate an after-fix formatter or provider-error run with invalid status text.
  • [P1] The branch is behind current main, so its exact merge result and current-main overlap should be refreshed before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared 100–599 validation boundary for every text-derived HTTP prefix, then land only after a redacted real formatter/provider-error transcript confirms invalid prefixes are no longer presented or classified as HTTP statuses.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining merge gate is contributor-supplied real behavior proof plus a routine refresh against current main, not a narrow automated code repair.

Security
Cleared: The patch only tightens local numeric parsing and adds tests; it introduces no dependency, permission, execution, or supply-chain change.

Review details

Best possible solution:

Keep one shared 100–599 validation boundary for every text-derived HTTP prefix, then land only after a redacted real formatter/provider-error transcript confirms invalid prefixes are no longer presented or classified as HTTP statuses.

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

Yes from source inspection: a three-digit prefix such as 000, 099, 600, or 999 reached HTTP parsing before this branch’s shared range check; no current-main runtime reproduction was independently established here.

Is this the best way to solve the issue?

Yes for the proposed boundary: centralizing the 100–599 check in extractHttpStatusMatch and reusing it in all discovered text-prefix consumers avoids divergent parser behavior.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded shared error-formatting and retry-classification correctness fix with limited but user-visible blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused test output, but it lacks redacted after-fix terminal, live-output, or runtime-log evidence showing invalid plain-text and provider-wrapped prefixes no longer receive HTTP treatment; add that proof to the PR body and request a re-review if needed. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source -2, Tests +87. Total +85 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 10 -2
Tests 1 87 0 +87
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 95 10 +85

What I checked:

  • Shared parser validation: The proposed helper now rejects non-integer values and values outside 100–599 before returning a parsed status, covering both leading and provider-wrapped extraction paths. (src/shared/assistant-error-format.ts:106, ae83f94090c5)
  • Remaining formatter paths covered: The follow-up commit replaces direct three-digit prefix handling in both parseApiErrorInfo and formatRawAssistantErrorForUi with extractHttpStatusMatch, resolving the previous review cycle’s remaining-parser finding. (src/shared/assistant-error-format.ts:173, ae83f94090c5)
  • Focused regression coverage: The new test file covers valid boundary-range statuses and rejects invalid leading and provider-wrapped values; the PR body additionally reports the Ollama retry-path regression test. (src/shared/assistant-error-format.test.ts:1, ae83f94090c5)
  • Follow-up provenance: Commit ae83f94 was authored after the prior ClawSweeper review and is specifically titled “validate all parsed HTTP status prefixes,” matching the repaired parser coverage. (src/shared/assistant-error-format.ts:173, ae83f94090c5)

Likely related people:

  • steipete: Authored the current follow-up commit that broadens the fix to the remaining parsing paths and was assigned on this PR. (role: follow-up author and assigned reviewer; confidence: medium; commits: ae83f94090c5; files: src/shared/assistant-error-format.ts, src/shared/assistant-error-format.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-18T08:00:06.132Z sha 35d9be0 :: needs real behavior proof before merge. :: [P2] Validate status codes in the remaining formatter parsers

@steipete steipete self-assigned this Jul 18, 2026
@steipete
steipete merged commit a941d3a into openclaw:main Jul 18, 2026
115 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…claw#110554)

* fix(shared): reject HTTP status codes outside the 100-599 range

extractHttpStatusMatch only checked Number.isFinite, so 3-digit
sequences such as "000", "099", "600", and "999" were accepted as
valid HTTP statuses. Downstream code then surfaced them as "HTTP 0"
in user-visible messages and fed them into retry/classification
branches (e.g. isCloudflareOrHtmlErrorPage checks `code < 500` and
`code < 600`). Restrict the extracted code to the IANA HTTP status
code range (100-599).

Co-authored-by: Patrick Erichsen <[email protected]>

* fix(shared): validate all parsed HTTP status prefixes

---------

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

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants