Skip to content

GET /api/v1/packages/:id silently ignores ?version= — the only serving surface never reads it, and the handler that did was deleted with the REST twin #17416

Description

@os-justin

Found while implementing #12034 (SDK-side binding of packages.get); out of that card's scope, which is the response shape only.

The defect

GET /api/v1/packages/:id accepts a ?version= query parameter from the SDK and the only surface that serves the route never reads it. The caller is answered 200 with the installed version, and nothing in the status, headers or body distinguishes that from a version-scoped read that actually happened.

The SDK still sends it. ScopedEnvironmentClient.packages.get in packages/client/src/index.ts takes version as its second argument and appends it:

get: async (id: string, version?: string) => {
  const qs = version ? `?version=${encodeURIComponent(version)}` : '';
  const res = await this.parent._fetch(this.url(`/packages/${encodeURIComponent(id)}${qs}`));
  ...
}

The serving handler is the runtime dispatcher's /packages domain (packages/runtime/src/domains/packages.ts, the parts.length === 1 && m === 'GET' branch). It reads the path id and nothing else — query is never touched on that branch:

const id = decodeURIComponent(parts[0]);
const pkg = registry.getPackage(id);

Why it is a regression rather than an always-dead parameter

The parameter was honoured until recently, by the REST registrar's twin of this route. #16628 (fix(rest): the dispatcher's /packages domain is the one implementation of the package read and delete routes (#14503), merged 2026-09-08) deleted that handler, and the deleted code read the parameter and guarded its arity:

const requested = readSingleQueryValue(req.query?.version);
if (...) {
  sendError(res, 400, 'VALIDATION_ERROR', repeatedQueryParamMessage('version', requested.count));
}
const version = requested.value || 'latest';
const pkg = await packageService.get(packageId, version);

So the deletion, which was correct about the one-route-one-owner problem it was solving, silently dropped a request-side capability along with the duplicate response shape. The dispatcher never had that read to inherit.

Repro

Against any host serving the dispatcher's /packages domain, with com.acme.crm@1.0.0 installed:

  • GET /api/v1/packages/com.acme.crm?version=99.0.0 answers 200 with the 1.0.0 row.
  • Expected: either the 99.0.0 record, or a refusal naming version.

The environment-scoped mount reaches the same handler through the @objectstack/hono catch-all, so scoped.packages.get(id, '99.0.0') has the same outcome from the SDK.

Why this is filed rather than fixed in #12034's PR

The fix is a decision, not a mechanical repair — three defensible answers, and they differ on the wire:

  1. Restore the version-scoped read in the dispatcher branch (with the arity guard the deleted handler carried), making the SDK parameter true again.
  2. Remove version from the SDK signature and let the route be identity-only.
  3. Refuse it — declare the route's closed query-parameter set per the Route and surface ownership rule so an unrecognised name gets a located 400 instead of being dropped.

Option 3 is the one the repo's own standing rule points at for a GET route that reads req.query, and it composes with either of the first two. Whichever is chosen, it is a producer-side wire change and wants its own ruling.

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions