Repository navigation
Fix skill details for symlinked skill directories - #5556
Merged
Merged
Conversation
# Conflicts: # packages/host-daemon-contract/src/protocol.ts # packages/host-daemon-contract/test/contract.test.ts
Resolve the followed root inside readRootRelativeFileForTransport so a dangling or removed skill directory returns ENOENT instead of a raw filesystem error. Drop the duplicate absolute-path check and move the docs paragraph to the end of the File Content Routes section. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 26, 2026
…read (#6335) ## Human comments ## What was wrong `host.write_file` without `expectedSha256` overwrote its target in place, so a crash or full disk partway through left a truncated file. `host.read_file_relative` loaded whole files with no size limit and sent them as one base64 WebSocket message. Both bugs came from duplicated paths. There were two whole-file reads: `read_file_relative` was built for the status-folder server, removed in June, and its only remaining caller was the provider-skill read. There were also three hand-written copies of the temp-file, hash-check, rename save, so a fix in one never reached the others. ## What changed - **One atomic save:** new dependency-free package `@bb/file-transfer`. `verified-file-transfer.ts` (from #6332/#6330) moved into it unchanged, apart from the `durable` and `mode` arguments below. A new `replaceFile` does the whole save: 1. check the expected hash; 2. write and fsync a fixed-length `.bb-write-<uuid>` temp file next to the target; 3. put it in place: - **no hash:** rename over the target; - **`expectedSha256: null`:** no-clobber link; - **a hash:** re-check, then rename. - **Who uses it:** `writeHostFile` keeps only root confinement, parent creation and error mapping. The server-owned skill save in `skill-listing.ts` calls `replaceFile` directly instead of its own copy. - **Modes:** an existing file keeps its mode exactly. A requested mode on a new file goes through `open()`, so the umask applies, as on main. - **Read-only folders:** an unconditional write falls back to overwriting in place, as on main. A hash-checked save fails with `EACCES`, as on main. - **fsync:** `writeVerifiedFile` takes `durable` (user saves fsync; attachments and skill trees don't) and an explicit create-or-exact `mode`. - **One whole-file read:** removed `host.read_file_relative`. The skill read now uses `host.read_file`, which has the 25 MB (10 MB image) cap. - **Symlinked skill folders:** `host.read_file` gains a required `followRootSymlink` boolean, matching `host.list_files`, so linked skill folders still resolve (#5556). Skill reads pass `true`; every other caller passes `false`. The schema rejects `true` with a git `ref` or without a `rootPath`. - **Server-side path checks:** the server rejects absolute, `..` and dotfile skill paths before calling the host, using the same check server-owned skills already used. - **Errors:** an oversized skill file now returns 413 instead of 502. - **Wire change:** `HOST_DAEMON_PROTOCOL_VERSION` goes from 255 to 256, for the removed command and the new required field. `host.write_file`'s fields and results are unchanged. - **Docs:** updated the symlinked-skill paragraph in `docs/debugging-and-qa.md`. - **Behaviour note:** saves replace the file, so hard links, xattrs and ACLs on an overwritten file aren't carried over. Hash-checked saves already worked this way. ## How you verified - **New tests:** - `@bb/file-transfer`: - an interrupted write leaves the original intact; - read-only folder: an unconditional write lands in place, a hash-checked save is refused; - a requested mode respects the umask; - a 240-character filename saves. - daemon: an oversized read under a followed root is rejected. - server: - oversized skill file → 413; - absolute, `..` and dotfile skill paths are rejected without calling the host; - server-owned skill save writes on a fresh revision and returns 409 on a stale one. - Each failed before its fix. - **Commands:** - `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`: 133/133 tasks pass. - `pnpm exec turbo run test` for `@bb/file-transfer` (7), `@bb/host-daemon-contract` (76), `@bb/host-daemon` (833, 12 skipped) and `@bb/server` (3655 of 3656). The one server failure is a timeout in `builtin-plugins.test.ts`, which nothing on this branch touches. A different test in that file timed out on each full run, both under heavy machine load, and that file's 28 tests pass when run alone. - **Manual:** a `pnpm start:worktree` instance with a fixture project, checked by a script of 24 CLI/API checks, all passing: - symlinked skill reads, the 27 MB → 413 case, rejected paths; - daemon- and server-saved skills: fresh save lands, stale save returns 409, no temp files left behind; - `bb file write`: unconditional, stale hash, read-only folder; - the umask and long-filename cases. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: review <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Imported skills discovered through a symlinked directory retain their logical path. The Skills detail page and CLI then use that directory as the root for
host.read_file_relativeandhost.list_files, whose host-side validation rejects symlink roots. A listed, readable Pi skill therefore showsFailed to load SKILL.md.; bothbb skill showandbb skill filesreturn HTTP 502. This remains reproducible with the file handler from upstreammainat05771e3c82404328854468f0fff7f0f8203e2076. The reproduction and investigation are in #5555. Merged #5519 fixes discovery, while this change fixes the subsequent detail reads.What changed
followRootSymlinkboolean to the two host file RPCs. The server opts in for skill content and file-list reads; other callers explicitly passfalse.HOST_DAEMON_PROTOCOL_VERSIONfrom 240 to 241 for the required wire fields, update existing callers and contract fixtures, and document the policy indocs/debugging-and-qa.md.ENOENTerror instead of a raw filesystem error.How you verified
Reproduced the installed BB 0.46.0 failure using both
bb skill showandbb skill filesagainst a real Pi directory link. The targetSKILL.mdexists and resolves successfully.Added an owner-boundary regression covering listing a linked directory, reading
SKILL.mdand a nested reference, hiding dotfiles, rejecting.., and rejecting a nested link escaping the resolved root. Withhost-files.tstaken from latest upstreammain, it fails withPath "…/research" must not be a symlink; it passes with this fix.Extended the server skill-detail test to check that both RPCs receive the explicit opt-in. Existing generic file-root rejection tests continue to pass with
false.After rebasing onto the checked upstream
main, all 168 focused tests passed:Formatting and
git diff --checkpassed. Source verification used Node 22.19.0 and pnpm 9.15.0 on macOS arm64. The installed desktop app was not replaced; post-fix browser/desktop UI verification has not been run.Commandeered by a maintainer: merged current
main(protocol 240 → 241) and added the missing-root handling above, with a dangling-link case in the regression test. Re-ran the focused host-daemon, server (8 files touching these RPCs), and contract suites plus lint/typecheck; all pass.Fixes #5555