Repository navigation
Commit 01178c0
fix(client): storage.upload sends application/octet-stream for a file of unknown type (#28187)
Fixes #28157
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia
## What changes
- `packages/client/src/index.ts` (`storage.upload`): the presigned
request now sends `mimeType: file.type || 'application/octet-stream'`
instead of `file.type` bare. A typed file keeps its own type.
- `packages/client/src/storage-wire-dialect.test.ts`: two cases beside
the existing storage wire tests. A `File` with `type: ''` produces a
presigned request whose `mimeType` is `application/octet-stream`;
control: a `File` typed `image/png` keeps `image/png`.
- `content/docs/api/plugin-endpoints.mdx`: one sentence under the
storage table saying the helper sends `application/octet-stream` for a
file of unknown type.
- `.changeset/28157-upload-unknown-mime-type.md`: `@objectstack/client`
patch.
The presigned door
(`packages/services/service-storage/src/storage-routes.ts`) is not
touched: its `400 INVALID_REQUEST` on an empty `mimeType` is the
published contract (`GetPresignedUrlRequestSchema.mimeType` is
`min(1)`).
Other SDK sites checked: `storage.upload` is the only place in
`packages/client/src` that derives this door's `mimeType` from a
`File`/`Blob` (`grep -n "\.type\b"` and `grep -rn mimeType` over
`packages/client/src`, non-test, at `d70e94ae`: one hit, line 5371).
`getPresignedUrl` and `initChunkedUpload` take a caller-built request;
`uploadPart` and `resumeUpload` send no `mimeType`.
## Why
A browser `File` whose type the browser does not know carries `type ===
''`. The SDK sent that empty string, the door refused it with `400
INVALID_REQUEST`, and the user could not attach the file at all.
## Verification
Premise, measured on `d70e94ae` (unit level): with the fix reverted, the
new case reads `"mimeType": ""` off the presigned request.
Pin bites (fix committed first, then reverted in the tree, then restored
with `git restore --source=HEAD --staged --worktree`):
```
fix reverted: Tests 1 failed | 11 passed (12)
- "mimeType": "application/octet-stream",
+ "mimeType": "",
restored: Tests 12 passed (12)
```
- `@objectstack/client` `pnpm test`: 52 files, 682 tests passed, exit 0.
- `@objectstack/client` `pnpm typecheck` (tsc + `check:test-typecheck`):
exit 0.
- Lint in the repo's form (`eslint --no-inline-config`) over the two
changed `.ts` files: exit 0.
- `dispatch-gates --commands` over the four changed paths: 88 commands,
each run with its exit code recorded. Two first exited 3
(`check:skill-examples`, `check:dual-build-cjs-loads`: no `dist/` to
read). After `pnpm build` both exited 0. `dispatch-gates --ran`: 88
derived, 88 run, 0 NOT-MEASURED, 0 UNRUN.
- `origin/main` moved 5 commits since `d70e94ae`. None touches
`packages/client`, the storage routes, the storage schema or the docs
page, so no merge.
Skills-docs: `grep -rn "storage\.upload\|mimeType" skills` has one hit,
`skills/objectstack-ai/SKILL.md:237` (`mimeTypes?` on a knowledge
source, unrelated), so no skill text changes.
`content/docs/api/plugin-endpoints.mdx` gains the one sentence above.
`content/docs/api/client-sdk.mdx:504` only shows the call and is
unchanged.
Clause-②: no
Metadata-protocol: none
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (scoped to the changed
files).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [ ] The *Before Submitting* list in CONTRIBUTING.md is done. (Not run:
the full repo-wide `pnpm test`. The client package suite and the 88
derived gates were run instead.)
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4czuTWNgKR22fKv7jia)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent d359857 commit 01178c0
4 files changed
Lines changed: 80 additions & 2 deletions
File tree
- .changeset
- content/docs/api
- packages/client/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5366 | 5366 | | |
5367 | 5367 | | |
5368 | 5368 | | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
| 5372 | + | |
| 5373 | + | |
5369 | 5374 | | |
5370 | 5375 | | |
5371 | | - | |
| 5376 | + | |
5372 | 5377 | | |
5373 | 5378 | | |
5374 | 5379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
0 commit comments