fix(packages): reject duplicate package id on POST /packages with 409 - #2971
Merged
Conversation
POST /api/v1/packages was an upsert — creating a package whose id already exists silently overwrote its manifest (name/version/…) with no warning, a data-loss footgun surfaced in Studio package-create dogfooding. It now returns 409 Conflict when the id already exists, and 400 when the id is missing. Intentional upgrade / re-install flows opt back in with `overwrite: true` (body) or `?overwrite=true`; the registry-level same-id reinstall path is untouched. Adds 4 handlePackages tests (create / duplicate-409 / overwrite / missing-id). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 16 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
added a commit
that referenced
this pull request
Jul 16, 2026
…lows (#3007) POST /packages now 409s when the manifest id is already installed (#2971, duplicate-id guard). The SDK's packages.install() had no way to opt into the intentional-overwrite escape hatch, so any upgrade / re-install flow built on it would hit the 409 with no recourse. Add `overwrite?: boolean` to the options bag and pass it through the POST body only when explicitly set — the default request stays byte-identical so the server keeps rejecting duplicate ids. First SDK tests for packages.install (default omits the flag; overwrite:true carries it). Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
68 tasks
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.
Problem
POST /api/v1/packageswas an upsert: creating a package whose id already exists silently overwrote its manifest (name/version/…) with no warning — a data-loss footgun surfaced during Studio package-create dogfooding (create a package with an existing id → 201, the existing manifest is clobbered).Change
handlePackagesnow, onPOST /packages:overwrite: true(body) or?overwrite=trueescape hatch so intentional upgrade / re-install flows still work.The registry-level same-id reinstall path (
installPackage, used by programmatic reload/upgrade) is left untouched — only the REST create path gains the guard.Tests
Adds 4
handlePackagestests: create (id free → 201), duplicate → 409 (no overwrite),?overwrite=true→ 201, missing id → 400. Two pre-existing install tests had their mock registry completed withgetPackage(the real registry always has it).🤖 Generated with Claude Code