fix(sync): avoid canonicalize on WASI preopened dirs#79
Merged
Conversation
The sync plugin's scan step called `Path::canonicalize` on the manifest `dir`. On wasm32-wasip2 that calls `realpath`, which returns ENOENT for any path under a preopen whose guest name has more than one component (e.g. `src/frontend/dist`), even though ordinary access works. Nested `dir`s therefore failed with "canonicalize src/frontend/dist: No such file or directory"; single-component dirs like `dist` happened to work. Build the scan root by prepending `/` to the (host-validated, relative, `..`-free) manifest dir instead. This matches the shape canonicalize produced for single-component dirs and uses only plain wasi:filesystem ops the preopen supports. Adds an e2e fixture + test using a nested `dirs` entry, which reproduces the failure without the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Ports the WASI
canonicalizefix from themigrationbranch (#71) tomain.Problem
The sync plugin's scan step canonicalized the manifest
dir. Onwasm32-wasip2,Path::canonicalizecallsrealpath, which returnsENOENTfor any path beneath a preopen whose WASI guest name has more than one component (e.g.src/frontend/dist) — even thoughread_dir/metadata/readthrough that preopen work fine. So a nesteddirfailed:Single-component dirs like
disthappened to canonicalize to/distand worked, which is why the existing fixtures never caught it. (Originally reported on the forum against the migration recipe; same root cause lives here.)Fix
Build the scan root by prepending
/to the (host-validated, relative,..-free) manifest dir instead of canonicalizing. This yields the same shape canonicalize produced for single-component dirs (/dist,/src/frontend/dist) and uses only plainwasi:filesystemops the preopen supports.main'sscan()had a singlecanonicalizecall;walkalready usesread_dirpaths rooted at that dir, and_headers/_redirectsload via relative paths — none of which need canonicalization.Test
Adds an e2e fixture +
nested_dir_deploytest usingdirs: [src/frontend/dist]with a nested subdir asset. Verified it fails with the exact error above when the fix is reverted, and passes with it.cargo test -p sync-core— 188 passcargo test -p e2e --test sync— 7 pass (incl. nested regression)cargo clippy -p sync-core— cleanNote: this is the same fix already shipped on
migrationasmigration-v2.2.1(consumed byasset-canister-v2.2.1).