Skip to content

fix(gateway): reject blank session history keys - #85261

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
cropsgg:main
Aug 5, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
cropsgg:main

Conversation

@cropsgg

@cropsgg cropsgg commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a blank encoded session-history key such as %20 matched the core route but was treated as a route miss, allowing the request to fall through to plugin, Control UI, or generic 404 routing instead of returning the endpoint's owned 400 response.

Malformed percent encoding such as %zz already returned 400; the regression proof keeps that behavior covered alongside the repaired blank-key case.

Why This Change Was Made

The session-history route parser now returns a tagged three-state result for route miss, invalid key, and valid key. This matches the adjacent session-kill route contract and removes the hidden null/empty-string sentinel pair that caused the shipped fallthrough.

The rewrite keeps parsing at the owning route boundary and leaves valid-key auth, canonical session lookup, transcript reads, pagination, SSE, plugin routing, and Control UI behavior unchanged.

User Impact

Blank session-history keys now receive a clear HTTP 400 invalid session key response. They no longer escape into unrelated fallback routing. Valid session history requests are unchanged.

The bug originated with the direct session-history endpoint in #50101 and is present in stable v2026.6.11 and v2026.7.2-beta.7.

Evidence

Validated commit: 2b17804fbd537b75d850bbdd16e146be4bc700a7

Stable patch ID: 9b37ea9d8aae7cf31acccbed47f9f817c7c91368. The signed commit is rebased directly onto current main 3faa2b08882319e7eec039eabd21abf7d021b243 and remains patch-identical to the clean P1 autoreview candidate d1899a6cd63bac4b43fa86f26a152d02ded33297 and prior reviewed head 467e479798f23d6582d9128a553e50ab52ea51e4.

Failure-first proof on untouched current main:

/sessions/%20/history -> HTTP 404

Real listening-Gateway proof after the repair:

/sessions/%20/history -> HTTP 400
{"error":{"message":"invalid session key","type":"invalid_request_error"}}

/sessions/%zz/history -> HTTP 400
{"error":{"message":"invalid session key","type":"invalid_request_error"}}

Focused and sibling coverage:

  • src/gateway/sessions-history-http.test.ts: 73 passed
  • src/gateway/session-kill-http.test.ts: 13 passed
  • total: 86 passed

Static and changed-surface proof:

The backing Actions job shows Run Testbox cancelled because the successful one-shot wrapper stopped its externally owned lease; the wrapper reported exitCode: 0 and runStatus: succeeded.

P1 autoreview on the patch-identical candidate returned no findings with 0.98 confidence. Independent owner-path and history reviews also found no blocking issue.

Production delta: +18/-7 (net +11) for the explicit owner-boundary state contract.

Regression delta: +18 for real listening-Gateway coverage.

No config, protocol, auth, persistence, migration, or public API changes.

Punchcard-Session: clear-orchard-lantern-bc

@cropsgg
cropsgg requested a review from a team as a code owner May 22, 2026 07:01
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: S labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 3:33 AM ET / 07:33 UTC.

ClawSweeper review

What this changes

The PR makes the Gateway session-history endpoint reject blank or malformed encoded session keys with HTTP 400 instead of allowing them to continue through later routing.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No actionable finding: current main still lets a blank encoded session-history key fall through after the route was admitted, while this exact-head patch returns the endpoint-owned 400 and preserves valid-key handling.

Priority: P2
Reviewed head: 2b17804fbd537b75d850bbdd16e146be4bc700a7

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The exact-head patch is narrowly scoped, owner-correct, and supported by direct Gateway behavior proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body and exact-head test show a real listening Gateway changing blank and malformed session-history requests from fallthrough to the expected HTTP 400 response.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body and exact-head test show a real listening Gateway changing blank and malformed session-history requests from fallthrough to the expected HTTP 400 response.
Evidence reviewed 5 items Current-main defect: The main parser normalizes a decoded whitespace-only key to null, and the handler returns false for that value; the request-stage loop therefore continues into later handlers.
Endpoint-owner repair: The PR separates unmatched, matched-invalid, and valid-key results, returning the owned invalid-request response only for the matched-invalid case.
Boundary-level regression proof: The added test starts the Gateway harness and performs direct loopback HTTP requests for both %20 and %zz, asserting the exact 400 JSON response.
Findings None None.
Security None None.

How this fits together

Gateway HTTP routing admits session-history paths before plugin and Control UI routing. The endpoint parser decides whether to serve history, return an invalid-request response, or leave a genuine route miss for later handlers.

flowchart LR
A[HTTP request] --> B[Gateway route admission]
B --> C[Session-history parser]
C --> D{Path result}
D -->|Route miss| E[Later plugin or UI routing]
D -->|Invalid key| F[Owned HTTP 400]
D -->|Valid key| G[Session history response]
Loading

Before merge

  • Complete next step (P2) - No repair job is needed: the exact PR head has no actionable defect, leaving only normal exact-head CI and merge gating.
Agent review details

Security

None.

PR surface

Source +11, Tests +18. Total +29 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 18 7 +11
Tests 1 18 0 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 36 7 +29

Review metrics

Metric Value Why it matters
Production vs test delta production +18/-7 (net +11), tests +18 The small production increase is justified by replacing an ambiguous route-state sentinel with an explicit owner-boundary result contract.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/sessions-history-http.test.ts, serialized state: src/gateway/sessions-history-http.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge this exact head once the normal required CI and native merge gates complete successfully.

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

Yes. Current main maps a decoded blank key to the same null sentinel as a route miss, and the supplied exact-head loopback Gateway proof exercises both blank and malformed encoded keys.

Is this the best way to solve the issue?

Yes. The three-state parse result repairs the fault at the endpoint owner boundary, mirrors the sibling session-kill contract, and leaves valid-key authorization and history behavior intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded Gateway HTTP error-handling defect with a clear user-visible response improvement and limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body and exact-head test show a real listening Gateway changing blank and malformed session-history requests from fallthrough to the expected HTTP 400 response.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and exact-head test show a real listening Gateway changing blank and malformed session-history requests from fallthrough to the expected HTTP 400 response.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Current parser and sibling route lines blame to this recent main commit; they also authored the exact PR head. (role: recent Gateway-area contributor; confidence: high; commits: fd1662f49cc3, 2b17804fbd53; files: src/gateway/sessions-history-http.ts, src/gateway/session-kill-http.ts)
  • clay-datacurve: The supplied merged feature provenance identifies this contributor for the original direct session-history endpoint. (role: original session-history feature contributor; confidence: medium; commits: 7b61ca1b0615; files: src/gateway/sessions-history-http.ts, src/gateway/sessions-history-http.test.ts)

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-31T12:01:01.032Z sha b6ffafd35d7155a26d18ea6e09ada4b89513c8f8 :: needs real behavior proof before merge. :: [P1] Use the shared lazy import loader
  • reviewed 2026-08-04T16:06:06.814Z sha 43fac8bd1b8faa751801911b62c5f7299ae46c95 :: needs real behavior proof before merge. :: [P2] Model route state without an empty-string sentinel
  • reviewed 2026-08-04T17:14:50.398Z sha 43fac8bd1b8faa751801911b62c5f7299ae46c95 :: needs real behavior proof before merge. :: [P2] Replace the empty-string route-state sentinel
  • reviewed 2026-08-04T19:21:03.942Z sha e4d879b75c446e1826a1bf293313c5015d03496b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T20:03:50.484Z sha e4d879b75c446e1826a1bf293313c5015d03496b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T21:04:12.009Z sha e4d879b75c446e1826a1bf293313c5015d03496b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T00:20:24.599Z sha 051c8a5bd1cd26a291d4513421bae9a926e2ac42 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T07:21:29.218Z sha 467e479798f23d6582d9128a553e50ab52ea51e4 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 22, 2026
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed stale Marked as stale due to inactivity labels Jul 20, 2026
steipete added a commit that referenced this pull request Jul 29, 2026
Preserve append-only text, fail impossible rewritten streams after usage resolves, and keep required client-tool output buffered until validation.

Refs: #85261

Co-authored-by: Achyut Mukund <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…#115799)

Preserve append-only text, fail impossible rewritten streams after usage resolves, and keep required client-tool output buffered until validation.

Refs: openclaw#85261

Co-authored-by: Achyut Mukund <[email protected]>
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jul 31, 2026
@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The maintainer rewrite is now at exact signed head 43fac8bd1b8faa751801911b62c5f7299ae46c95. It removes every unrelated branch change and keeps only the session-history route-owner fix plus real HTTP fallback proof. The PR body has the failure-first result, exact response, Blacksmith gate, and exact-head autoreview result.

@vincentkoc vincentkoc changed the title fix(gateway): streaming double-finalization, replace-event accumulation, session-key 400, module cache retry, trusted-proxy case sensitivity fix(gateway): reject invalid session history keys Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Exact head e4d879b75c446e1826a1bf293313c5015d03496b addresses every rank-up move from the prior review:

  • replaced the empty-string sentinel with a tagged miss/invalid/valid route result;
  • added real listening-Gateway coverage for %20 and %zz;
  • updated the PR body with failure-first output, both after-fix HTTP responses, shipped-version provenance, focused tests, and changed-gate proof.

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Co-authored-by: Achyut Mukund <[email protected]>
Punchcard-Session: clear-orchard-lantern-bc
@vincentkoc

Copy link
Copy Markdown
Member

ClawSweeper rank-up disposition: no separate repair job is required because the exact review found no actionable findings. The branch is now rebased directly onto current main as 2b17804fbd537b75d850bbdd16e146be4bc700a7, with stable patch ID 9b37ea9d8aae7cf31acccbed47f9f817c7c91368. Remaining work is the normal exact-head CI, ClawSweeper, and native merge gates.

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(gateway): reject blank session history keys This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@vincentkoc
vincentkoc merged commit 7617e91 into openclaw:main Aug 5, 2026
125 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
Punchcard-Session: clear-orchard-lantern-bc

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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants