Repository navigation
fix(file): bind copied workspace files to their source by storage key - #9209
Merged
Merged
Conversation
The File operations resolved a selected workspace file's storage key through the VFS reference resolver, which only understands ids, paths, and names, so a key never resolved. Every copy, archive, or content read of a workspace file given as a file object lost its source identity: the write recorded the copy's secret provenance as unknown and later reads of the copy were refused. Picker values passed to manage_sharing failed with "File not found" the same way. Resolve the key to its current workspace file row first, then authorize that row by id under the operation's policy, and bind only when the row's current key is the key whose bytes are read. Gate on the key's storage prefix instead of the optional `context` field so a block reference without one also binds.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryFixes workspace file copies and picker-based sharing by resolving storage keys to authorized file records.
Review checks were static; tests were not run.
|
This branch was previously deployed
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.
Summary
writewithfileInput),compress,decompress, orcontentread of a workspace file passed as a file object lost its source identity. The copy was stored withunknownsecret provenance (an ERROR on every such write), and later reads of the copy were refused. Regressed when the operations moved in-process and the key-metadata lookup was replaced by the reference resolver.resolveWorkspaceFileStorageKeyto the workspace-file reference application module. It maps the key to its current workspace row, requires the asserted workspace, authorizes that row by id under the caller's operation policy, and returns it only if the row's current key is the key whose bytes are read. Anything else isnot_found, which callers already treat as "unbound", so they fail closed.bindSelectedContentFilenow gates on the key's storage prefix instead of the optionalcontextfield, so a block-reference file that has nocontextalso binds. File picker values were already gettingcontextinferred from the key.manage_sharinghad the same bug for picker values ({ name, path, key }) and always failed with "File not found". It now resolves through the same helper under the share policy.unknown; a superseded version key and another workspace's key are still refused.Type of Change
Testing
apps/sim/lib/internal/file/write-copy-provenance.integration.ts(real Postgres plus local storage, run through the real file operation, application authorization, metadata and provenance sidecars): 8/8 pass.operations.ts: 5 failures. A clean copy came outunknowninstead ofexactfor block references, block references without a context, and picker values. A copy of the caller's own secret-bearing file wasunknowninstead of exact with those entries.manage_sharingwith a picker key returned 404.contextgate restored: the block-reference-without-context case fails.unknown; a superseded version key and a foreign-workspace key are refused (404).lib/internal/file/,lib/workspace-files/application/,tools/file,lib/execution/payloads, the tool-execution suite, and the suites that use the reference mock all pass (813 tests).bun run lint,check:boundaries,check:comment-hygiene,check:test-patterns,check:explicit-any,check:file-names,check:source-conventions. Full type-check and audits are left to CI.Checklist
test-auditauthoring gate)