Skip to content

fix(file-transfer): report unreadable directory metadata - #173336

Merged
steipete merged 1 commit into
mainfrom
deslop/z12-1-dir-fetch-errors-20261015
Oct 15, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z12-1-dir-fetch-errors-20261015

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

dir_fetch silently skipped saved files when reading their metadata failed, then returned a successful incomplete manifest and recorded an allowed outcome. A real tool-boundary regression reproduces this: an extracted ok.txt whose stat fails is reported as “Fetched 0 files.”

User Impact

User impact: directory downloads now fail visibly if saved-file metadata cannot be read, instead of reporting a successful incomplete download. Successful downloads are unchanged; no migration or configuration change is needed.

Why This Change Was Made

Propagate metadata read failures instead of skipping the file. Keep archive extraction, path/policy authorization, size limits, hashing, attachment ordering and the existing successful manifest shape unchanged. Document the visible failure behavior and add one regression to the existing archive suite.

Best-effort tradeoffs accepted

  • A saved file removed or made unreadable before manifest construction now makes the tool fail visibly rather than returning a partial success. The swallowing catch dates to 0603c2327d3 (fix(file-transfer): require canonical node policy authorization #74742); no human report requiring partial-success behavior was identified. This repairs a reproduced silent failure, not a speculative concurrency mechanism.

Net LOC

Production: 6 net lines removed (+1/-7). Tests: 23 added. Documentation: 3 added. This is a bug-fix exemption, not a qualifying large cleanup PR.

Evidence

  • Baseline: new tool-boundary regression fails for the intended reason, returning success with fileCount: 0 instead of rejecting the injected metadata error.
  • Fixed: all 18 dir-fetch-tool.test.ts cases pass, including archive path/link/collision/expansion protections. Wrapper wall time 161.12 seconds; test-file wall time 138.79 seconds on the loaded shared host. Hosted CI timing pending.
  • Lint-suppression suite: 3/3 pass; no new suppressions.
  • Fresh independent review of the exact production/test patch: no accepted P0–P2 findings. Documentation adds only the corresponding failure description.
  • Source-mapped typecheck of the changed production graph passes. The secondary checkout's package-boundary type/lint attempts correctly refused its shared dependency links; source-mapped proof ran in the owning dependency checkout with the same tool implementation.
  • Runtime cycles: 0; Madge cycles: 0. Formatting passes on all three files; diff whitespace check passes.
  • Changed-file checks passed conflict markers, line-cap growth and assertion safety. They found stale max-lines baseline entries for two unchanged core test files, then remained capacity-bound in the repo-wide SQLite ratchet. Targeted lint reached the existing 300-second SDK declaration-preparation deadline before lint execution. These are local proof gaps, not claims of green or inherited CI. Exact-head hosted CI is the broad gate.

All runtime proof used task-owned HOME, OpenClaw state/config and XDG directories. No real Gateway/state or remote runner was used.

@clawsweeper

clawsweeper Bot commented Oct 15, 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 docs Improvements or additions to documentation plugin: file-transfer size: XS labels Oct 15, 2026
@steipete
steipete marked this pull request as ready for review October 15, 2026 17:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T17:35:56.689118Z 22954c5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22954c5e1c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} catch {
continue;
}
const { size } = await fs.stat(absPath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Settle metadata failures before rethrowing

When fs.stat rejects—the scenario added by this commit—execution leaves both savedTar.path and the extracted rootDir in managed media and exits before either audit call; only the extractArchive catch performs cleanup and records an error. Because this failure returns no paths, repeated failures can accumulate inaccessible 16 MiB archives and up to 64 MiB extracted trees while producing no file-transfer error record. Clean up the post-extraction artifacts and record the error before rethrowing.

AGENTS.md reference: AGENTS.md:L50-L52

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Make directory downloads fail when saved-file metadata cannot be read instead of returning an incomplete successful manifest.

Example: An extracted ok.txt contains "saved", but reading its metadata fails with EIO.

  • Before: The tool reports "Fetched 0 files" and records an allowed outcome.
  • After: The tool rejects with the metadata error.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused correction with a meaningful boundary regression, but its new failure path leaves artifacts and omits the transfer error record.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; its reported regression exercises the real directory-fetch tool and extraction with injected metadata failure, while node transport and media saving are mocked.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A directory download can claim success while silently omitting saved files whose metadata could not be read.
Reason: The change restores truthful transfer results with less production code, and the maintainer-authored body explicitly accepts whole-transfer failure for unreadable saved files.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it fixes a current silent failure, but the newly propagated metadata error bypasses artifact cleanup and transfer-error recording.

Priority: P2
Reviewed head: 22954c5e1c13c8305b2ad96f6bc5bc47668c3c31

Before merge

  • Clean up and audit the newly propagated metadata failure (P2) - When stat rejects for extracted ok.txt, this await now exits execute after the archive and extracted tree have been saved, but outside the extraction catch that removes them and records an error. No paths are returned, and neither audit call executes. Repeated failures can therefore leave unreported artifacts behind; default maintenance prunes outbound staging rather than this transfer namespace. Settle this failure with best-effort artifact cleanup and an error audit before rethrowing, and extend the regression to verify both outcomes.

Findings

  • [P2] Clean up and audit the newly propagated metadata failure — extensions/file-transfer/src/tools/dir-fetch-tool.ts:154

Tests

  • Missing end-to-end proof: The supplied regression uses real extraction with mocked node invocation and media saving; no shipped-entry-point run of the metadata failure is supplied.
Agent review details

How this fits together

The File Transfer plugin receives an authorized node archive, saves and extracts it in Gateway media storage, then builds the manifest and attachments returned to the agent.

flowchart LR
  A[Agent directory request] --> B[Authorized node invocation]
  B --> C[Archive payload]
  C --> D[Gateway media extraction]
  D --> E[Metadata and hashes]
  E --> F[Manifest and attachments]
  E --> G[Transfer audit]
Loading

Technical review

Best possible solution:

Propagate metadata failures after best-effort removal of the failed transfer's artifacts and recording its error outcome.

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

Current-main source deterministically skips a walked file when stat rejects; the added regression exercises that condition with EIO, and the body reports its baseline failure and fixed pass, which this read-only review did not rerun.

Is this the best way to solve the issue?

Removing the swallowing catch addresses the silent incomplete manifest directly, but failure settlement must cover the new rejection path.

Full review comments:

  • [P2] Clean up and audit the newly propagated metadata failure — extensions/file-transfer/src/tools/dir-fetch-tool.ts:154
    When stat rejects for extracted ok.txt, this await now exits execute after the archive and extracted tree have been saved, but outside the extraction catch that removes them and records an error. No paths are returned, and neither audit call executes. Repeated failures can therefore leave unreported artifacts behind; default maintenance prunes outbound staging rather than this transfer namespace. Settle this failure with best-effort artifact cleanup and an error audit before rethrowing, and extend the regression to verify both outcomes.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0c5d6813cfa9.

Provenance checked

  • Saved-file stat failure handling changes intended behavior with a stated reason (0603c23: The associated authorization repair required canonical paths and archive entries to be authorized before I/O; its stated rationale does not require successful partial manifests after metadata errors.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/file-transfer/src/tools/dir-fetch-tool.test.ts --maxWorkers=1
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0d7fb8e adds extensions/file-transfer/src/tools/dir-fetch-tool.ts:202 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0d7fb8eb392f; files: extensions/file-transfer/src/tools/dir-fetch-tool.ts)
  • Vincent Koc: Raw commit 8744037 adds extensions/file-transfer/src/tools/dir-fetch-tool.ts:79 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8744037721da; files: extensions/file-transfer/src/tools/dir-fetch-tool.ts)

PR surface

Source -6, Tests +23, Docs +3. Total +20 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 7 -6
Tests 1 23 0 +23
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 27 7 +20

Labels

Label changes:

  • add P2: A bounded directory-transfer failure is reported incorrectly on main, and the proposed correction needs focused cleanup and audit settlement.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: A bounded directory-transfer failure is reported incorrectly on main, and the proposed correction needs focused cleanup and audit settlement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 15, 2026, 1:48 PM ET / 17:48 UTC.

@steipete
steipete enabled auto-merge (squash) October 15, 2026 17:55
@steipete
steipete merged commit fce8ee9 into main Oct 15, 2026
192 of 197 checks passed
@steipete
steipete deleted the deslop/z12-1-dir-fetch-errors-20261015 branch October 15, 2026 18:09
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…3336)

## What Problem This Solves

`dir_fetch` silently skipped saved files when reading their metadata failed, then returned a successful incomplete manifest and recorded an allowed outcome. A real tool-boundary regression reproduces this: an extracted `ok.txt` whose `stat` fails is reported as “Fetched 0 files.”

## User Impact

User impact: directory downloads now fail visibly if saved-file metadata cannot be read, instead of reporting a successful incomplete download. Successful downloads are unchanged; no migration or configuration change is needed.

## Why This Change Was Made

Propagate metadata read failures instead of skipping the file. Keep archive extraction, path/policy authorization, size limits, hashing, attachment ordering and the existing successful manifest shape unchanged. Document the visible failure behavior and add one regression to the existing archive suite.

## Best-effort tradeoffs accepted

- A saved file removed or made unreadable before manifest construction now makes the tool fail visibly rather than returning a partial success. The swallowing catch dates to `535fb87d1c7` (openclaw#74742); no human report requiring partial-success behavior was identified. This repairs a reproduced silent failure, not a speculative concurrency mechanism.

## Net LOC

Production: 6 net lines removed (+1/-7). Tests: 23 added. Documentation: 3 added. This is a bug-fix exemption, not a qualifying large cleanup PR.

## Evidence

- Baseline: new tool-boundary regression fails for the intended reason, returning success with `fileCount: 0` instead of rejecting the injected metadata error.
- Fixed: all 18 `dir-fetch-tool.test.ts` cases pass, including archive path/link/collision/expansion protections. Wrapper wall time 161.12 seconds; test-file wall time 138.79 seconds on the loaded shared host. Hosted CI timing pending.
- Lint-suppression suite: 3/3 pass; no new suppressions.
- Fresh independent review of the exact production/test patch: no accepted P0–P2 findings. Documentation adds only the corresponding failure description.
- Source-mapped typecheck of the changed production graph passes. The secondary checkout's package-boundary type/lint attempts correctly refused its shared dependency links; source-mapped proof ran in the owning dependency checkout with the same tool implementation.
- Runtime cycles: 0; Madge cycles: 0. Formatting passes on all three files; diff whitespace check passes.
- Changed-file checks passed conflict markers, line-cap growth and assertion safety. They found stale max-lines baseline entries for two unchanged core test files, then remained capacity-bound in the repo-wide SQLite ratchet. Targeted lint reached the existing 300-second SDK declaration-preparation deadline before lint execution. These are local proof gaps, not claims of green or inherited CI. Exact-head hosted CI is the broad gate.

All runtime proof used task-owned HOME, OpenClaw state/config and XDG directories. No real Gateway/state or remote runner was used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant