Skip to content

fix(packages): reject duplicate package id on POST /packages with 409 - #2971

Merged
os-zhuang merged 1 commit into
mainfrom
feat/packages-duplicate-detect
Jul 15, 2026
Merged

fix(packages): reject duplicate package id on POST /packages with 409#2971
os-zhuang merged 1 commit into
mainfrom
feat/packages-duplicate-detect

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Problem

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 during Studio package-create dogfooding (create a package with an existing id → 201, the existing manifest is clobbered).

Change

handlePackages now, on POST /packages:

  • returns 409 Conflict when a package with that id already exists;
  • returns 400 when the id is missing;
  • accepts an explicit overwrite: true (body) or ?overwrite=true escape 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 handlePackages tests: create (id free → 201), duplicate → 409 (no overwrite), ?overwrite=true → 201, missing id → 400. Two pre-existing install tests had their mock registry completed with getPackage (the real registry always has it).

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jul 15, 2026 2:53pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

16 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx (via @objectstack/runtime)
  • content/docs/plugins/packages.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit b96ddab into main Jul 15, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the feat/packages-duplicate-detect branch July 15, 2026 15:28
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant