Skip to content

fix(composer): hold every dist of a version the minimum age holds - #477

Merged
M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/composer-dist-min-age
Nov 13, 2026
Merged

M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/composer-dist-min-age

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

Follow-up from the #473 review: the Composer proxy checked the minimum age only after comparing the dist reference.

Problem

locateComposerDist returned errNotFound when the reference in the request wasn't the one this proxy publishes, before checkGate ran. In a group of two Composer proxies of different upstreams, the merged p2 document can offer a version through the later member's dist URL. The earlier proxy, which holds that version back by its minimum age, answered 404. group.firstHit passes over a 404, so the later member served the version.

Curation didn't have this problem: serveComposerDist checks it from the path, before anything else.

Change

checkGate now runs before the reference comparison. A held version answers 403 for any reference; the minimum age holds the version, not one dist of it. Unchanged:

  • a version that is old enough answers 404 for a reference the proxy doesn't publish (a stale or forged URL);
  • a version the upstream doesn't publish answers 404;
  • a dist already in the cache is still served without locate.

With this, the rule from #471 ("the first member that has the version decides, held or not") holds for Composer as written. I removed the paragraph in hosted-proxy-group.md that documented the difference, and added an upgrade note.

Test

TestComposerProxy_MinAgeRefusesAnyReferenceOfATooNewVersion uses the aged fixture (1.1.0 published a minute ago, a 24 h gate):

  • another reference of 1.1.0 answers 403 (it answered 404 before the fix; I ran the test against the old order to confirm it fails);
  • another reference of the old-enough 1.0.0 answers 404;
  • an unpublished 9.9.9 answers 404;
  • the dist host is never contacted.

There's no group-level test. The group's behaviour on a member's 403 is already covered, and this PR only changes what the member answers. I can add one with two fake upstreams if you'd like it pinned end to end.

Checks

  • golangci-lint run ./... passes.
  • go test -short -race ./internal/proxy/ and go test ./internal/group/ pass.
  • make docs-check passes.

🤖 Generated with Claude Code

locateComposerDist compared the dist reference before checking the gate,
so a request for a held version under a reference this proxy does not
publish answered 404. In a group the merged p2 document can carry the
dist of a later member (another upstream, another reference); the
earlier proxy's 404 let group.firstHit pass on and the later member
served the version the earlier one holds back. The gate is now checked
first, so the answer is 403 whatever the reference, as for curation.

A version that is old enough, or that the upstream does not publish,
still answers 404 for an unknown reference. The paragraph of
hosted-proxy-group.md that described the gap is removed: the batch
availability answer now matches serving.

Refs openartifact#471.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@M0Rf30
M0Rf30 merged commit 1aef31f into openartifact:main Nov 13, 2026
23 checks passed
@orcamedia
orcamedia deleted the fix/composer-dist-min-age branch November 13, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants