Skip to content

fix(gateway): allow workspace retry after rejected upload - #123830

Merged
steipete merged 1 commit into
mainfrom
steipete/wizardly-bell-e217f1
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/wizardly-bell-e217f1

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a node workspace reconciliation upload that was rejected before staging began could leave the upload permanently marked active. A later reconciliation for the same workspace then failed with “Node workspace transfer upload is already active” instead of receiving a fresh upload token.

Why This Change Was Made

The transfer service now owns cleanup for the complete post-authorization receive lifecycle, including content-length validation and manifest parsing before a staging directory exists. Failed operations release the exact claimed upload while preserving delegated-authority checks, transfer limits, staging cleanup, and completed-upload publication.

This is intentionally separate from #123739, which fixed positive short writes. No short-write behavior is changed here.

User Impact

Node workspace reconciliation can recover from rejected or malformed upload requests by minting a fresh upload operation instead of leaving the workspace stuck until its transfer context is replaced.

Evidence

  • Pre-fix HTTP-boundary regression: node scripts/run-vitest.mjs src/gateway/worker-environments/node-workspace-transfer-service.test.ts failed 1 of 3 tests with Node workspace transfer upload is already active.
  • Post-fix focused proof: node scripts/run-vitest.mjs src/gateway/worker-environments/node-workspace-transfer-service.test.ts src/gateway/worker-environments/node-worker-tunnel.test.ts src/gateway/server-http.node-workspace-transfer.test.ts — 13 tests passed.
  • node scripts/check-changed.mjs -- src/gateway/worker-environments/node-workspace-transfer-service.ts src/gateway/worker-environments/node-workspace-transfer-service.test.ts — passed on Blacksmith Testbox tbx_01m0109bkrjxxjy9x370gcr5yc: https://github.com/openclaw/openclaw/actions/runs/31839270350
  • Targeted oxfmt --check, oxlint, and git diff --check passed.
  • Fresh Codex-backed branch autoreview reported no accepted/actionable findings.
  • Production LOC: +32/-31 (net +1). Tests: +22/-7 (net +15).

AI-assisted; the lifecycle owner, authority behavior, regression, and final rebased diff were independently reviewed.

Reset claimed workspace uploads when HTTP validation fails before staging so a later reconciliation can mint a fresh operation.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 14, 2026 20:59
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 5:44 PM ET / 21:44 UTC.

ClawSweeper review

What this changes

The PR releases a claimed node-workspace upload when validation or manifest parsing fails before staging begins, so a later reconciliation can mint a new upload token.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer handling: the patch repairs a source-proven Gateway upload-claim leak, and no blocking correctness or security finding was found.

Priority: P2
Reviewed head: 2a634ed7448abcd38bec075ebe37cf548edb2dc9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with a credible HTTP regression test and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored Gateway PR is outside the external-contributor proof gate; its body nevertheless supplies a focused before/after HTTP-boundary test transcript.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored Gateway PR is outside the external-contributor proof gate; its body nevertheless supplies a focused before/after HTTP-boundary test transcript.
Evidence reviewed 6 items Current-main failure path: Authorization changes the sole ready upload to receiving, while current main validates Content-Length before the cleanup scope; a rejected request therefore leaves the claimed upload present and the next prepare attempt rejects it as active.
Lifecycle-owner repair: The branch expands the receive cleanup scope over validation, parsing, directory creation, and staging; it removes a staging directory only when present and clears only the exact claimed operation.
Caller and HTTP contract: The HTTP adapter retains its 413 limit-error response, while the tunnel mints an upload, runs it, revokes its token, and consumes only a completed upload; neither caller is the right owner for leaked receiving state.
Findings None None.
Security None None.

How this fits together

Node workspace reconciliation uploads pass through the Gateway transfer service, which authorizes one upload claim, validates and stages its contents, then publishes the completed workspace to the tunnel. Failed requests must clear their claim without weakening the active-transfer authority fence.

flowchart LR
  A[Node workspace reconciliation] --> B[Gateway upload endpoint]
  B --> C[Authorize and claim upload]
  C --> D[Validate request and manifests]
  D --> E[Stage changed files]
  E --> F[Publish completed workspace]
  D --> G[Release failed upload claim]
  G --> A
Loading

Before merge

  • Resolve merge risk (P1) - Production code is net +1 line; the optional staging-root guard is necessary to distinguish pre-directory rejection from a directory that must be removed, so no safe net-neutral cleanup shape is apparent.
  • Complete next step (P2) - This maintainer-owned, protected-label PR has no discrete repair finding for an automated work lane.
Agent review details

Security

None.

PR surface

Source +1, Tests +15. Total +16 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 32 31 +1
Tests 1 22 7 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 54 38 +16

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +1 (32 added, 31 removed); tests +15 (22 added, 7 removed) The single production-line increase represents safe cleanup before directory allocation; the test increase adds HTTP-boundary proof for that formerly uncovered lifecycle interval.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/node-workspace-transfer-service.ts, unknown-data-model-change: src/gateway/worker-environments/node-workspace-transfer-service.test.ts, unknown-data-model-change: src/gateway/worker-environments/node-workspace-transfer-service.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep complete post-authorization receive cleanup in the transfer service, with an explicit optional staging root, then land after normal exact-head maintainer checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep complete post-authorization receive cleanup in the transfer service, with an explicit optional staging root, then land after normal exact-head maintainer checks.

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

Yes, source-reproducible at high confidence: on current main an authorized zero-length POST throws before cleanup, and the next upload preparation observes the still-active claim. The read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. Cleanup belongs to the transfer service that claims the upload; moving it to the tunnel would mask the owner leak and could disturb receiving or completed state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded Gateway workspace-recovery failure without evidence of data loss, security bypass, or broad runtime unavailability.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored Gateway PR is outside the external-contributor proof gate; its body nevertheless supplies a focused before/after HTTP-boundary test transcript.

Label justifications:

  • P2: This repairs a bounded Gateway workspace-recovery failure without evidence of data loss, security bypass, or broad runtime unavailability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored Gateway PR is outside the external-contributor proof gate; its body nevertheless supplies a focused before/after HTTP-boundary test transcript.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged workspace-transfer short-write repair that changed this same service and regression suite, in addition to this focused follow-up. (role: recent area contributor; confidence: high; commits: f8be386806d7; files: src/gateway/worker-environments/node-workspace-transfer-service.ts, src/gateway/worker-environments/node-workspace-transfer-service.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.

@steipete steipete self-assigned this Aug 15, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready on exact head 2a634ed7448abcd38bec075ebe37cf548edb2dc9.

  • Focused proof: node scripts/run-vitest.mjs src/gateway/worker-environments/node-workspace-transfer-service.test.ts src/gateway/worker-environments/node-worker-tunnel.test.ts src/gateway/server-http.node-workspace-transfer.test.ts — 13 tests passed.
  • Changed-path proof passed on Blacksmith Testbox tbx_01m0109bkrjxxjy9x370gcr5yc: https://github.com/openclaw/openclaw/actions/runs/31839270350
  • Fresh structured autoreview found no accepted/actionable findings.
  • Reviewed-head LOC: production +32/-31 (net +1); tests +22/-7 (net +15).
  • No persistent-data, SQLite schema, protocol, configuration, or upgrade-contract change.
  • ClawSweeper P1 resolved: accept the +1 production line because optional stagingRoot is the minimal state that distinguishes pre-directory failures from failures requiring directory removal; no safe net-neutral shape preserves that lifecycle distinction.
  • ClawSweeper P2 resolved: this protected maintainer PR has no automated repair lane and is completing through the repository-native review/prepare/merge flow.

Since the review, #123859 landed the same production cleanup as part of the broader transfer-scratch lifecycle repair. The merge remains conflict-free and this PR retains its distinct HTTP-boundary retry regression; native prepare verified the exact remote head with hosted gates.

@steipete
steipete merged commit 9d6b64c into main Aug 15, 2026
247 of 253 checks passed
@steipete
steipete deleted the steipete/wizardly-bell-e217f1 branch August 15, 2026 02:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
Reset claimed workspace uploads when HTTP validation fails before staging so a later reconciliation can mint a fresh operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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