fix: preserve Skills upload file paths#1856
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a20e148b58
ℹ️ 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".
| ''; | ||
|
|
||
| if (!name) return undefined; | ||
| if (opts?.stripFilename === false) return name; |
There was a problem hiding this comment.
Limit path-preserving mode to explicit file names
When stripFilename === false, this returns the raw value for every source (name, url, filename, and path), but Skills now enables that mode by default in both create calls. As a result, Response uploads use full URLs and stream uploads can use full filesystem paths (e.g., from fs.createReadStream(path.resolve(...))), which can violate the Skills “single top-level directory” filename contract and leak local paths in multipart metadata. Path-preserving mode should be restricted to caller-provided logical names, while inferred url/path values should still be reduced to a basename.
Useful? React with 👍 / 👎.
Fixes #1807.
This keeps the existing safe default for multipart uploads: filenames inferred from
File,Response, streampath, orfilenameare still stripped down to their basename unless a caller opts out.The Skills API is the exception because its upload contract requires files to live under a single top-level directory, such as
my-skill/SKILL.md.skills.create()andskills.versions.create()now opt into preserving filename paths when constructing multipart form data.Validation:
yarn test tests/form.test.ts