Repository navigation
Conversation
PUT_PRESIGNED_URL, DELETE_OBJECT and DELETE_OBJECTS accept any key, including `_fs/<volume>/...`, where org filesystem bytes live. The Library lists files from the `org_fs_entry` index, which only the /api/:org/fs routes write, so an agent that uploads to `_fs/home/pages/x.html` through a presigned URL gets bytes in the bucket and nothing in the Library; a raw delete leaves an index row with no bytes behind. Reject `_fs/` keys in those three tools (normalized like buildS3Key, so `a/../_fs/x` and encoded spellings count) and point to the fs route. Fix the decocms-studio skill, whose rest.md told agents to prefer those tools while the line above it said to write files through `fs`. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
4 tasks done
Contributor
|
Closing in favor of #7885, which includes this commit and builds on it: instead of rejecting |
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.
What is this contribution about?
An agent that wrote a file to the Library with
PUT_PRESIGNED_URL(key_fs/home/pages/x.html) got the bytes into the bucket but never saw the file in the Library. The Library lists from theorg_fs_entryPostgres index, which only the/api/:org/fsroutes (OrgFs.write()) maintain, so a raw write is invisible. A rawDELETE_OBJECTon an_fs/key does the reverse: it leaves an index row with no bytes.PUT_PRESIGNED_URL,DELETE_OBJECTandDELETE_OBJECTSnow reject keys in the_fs/namespace, with an error that points toPUT/DELETE /api/<org>/fs/<volume>/file(decocms api). The check normalizes the key likebuildS3Key(isOrgFsKeyinorg-fs-path.ts), soa/../_fs/x, a leading slash, backslashes and percent-encoded spellings are caught too.decocms-studioskill contradicted itself:rest.mdsaid "write files throughfs, notobject-storage" and then "Prefer the tools (PUT_PRESIGNED_URL,DELETE_OBJECT)". Both docs now send org files to thefsroutes and keep the tools for non-_fs/keys.No new CLI command:
decocms api(afterdecocms auth login) already reaches thefsroutes with the user's session.How did you verify your code works?
isOrgFsKey(spellings that must match and keys that must not, e.g.chat-uploads/_fs/a,_fsx/a),PUT_PRESIGNED_URLandDELETE_OBJECT(S)rejecting_fs/keys without touching storage, andDELETE_OBJECTstill deleting an ordinary key.bun test src/tools/object-storage src/file-storage/org-fs-path.test.ts: 20 pass, 0 fail.bun run fmt,bun run lint,bun run knipandapps/apitsc --noEmitare clean.bun test src/tools src/file-storagefails 97 tests with and without this change (base: 1123 pass / 97 fail; this branch: 1129 pass / 97 fail). They are the Postgres-backed integration suites and my machine has no local Postgres role. CI covers them.org_fs_entryrow existed for a file uploaded through the presigned URL, while neighbouring files written throughfshad rows.decocms apiwrite against prod from this branch.How to Test
PUT_PRESIGNED_URLwith{"key":"_fs/home/test.html"}. Expected: error naming the org filesystem and thefsroute.{"key":"uploads/test.txt"}. Expected: a URL, as before.decocms api "/api/<slug>/fs/home/file?path=test.html" -X PUT -H "Content-Type: text/html" -d @test.html. Expected:{entry}and the file shows up in the Library.Migration Notes
None. Existing orphaned objects under
_fs/(written before this change) stay invisible; they can be re-uploaded through thefsroute.Review Checklist
_fs/key)🤖 Generated with Claude Code
Summary by cubic
Causes object-storage tools to reject
_fs/keys so org files always go through the filesystem routes that maintain the Library index.PUT_PRESIGNED_URLwrote bytes to_fs/...without creating a Library entry, andDELETE_OBJECT(S)could remove bytes while leaving a stale index row.buildS3Key, catchinga/../_fs/x, leading slashes, backslashes, and percent-encoded spellings.decocms-studioskill now direct org files toPUT/DELETE /api/<org>/fs/<volume>/file.Written for commit 44e49f3. Summary will update on new commits.