registry/internal/validators/registries
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Thomas Thomsen d813d2b805
fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411)
Fixes #553.

The PyPI and npm validators fetch the version-specific metadata endpoint
(`/pypi/{name}/{version}/json` and the npm equivalent) and report any
non-200 as `<pkg> not found`. That endpoint 404s for two different
reasons though: the package doesn't exist, or it exists and only the
*version* is missing (e.g. a release that hasn't propagated yet). So a
valid package reads as gone:

```diff
- PyPI package 'requests' not found (status: 404)
+ PyPI package 'requests' exists, but version '99.99.99' was not found (status: 404). A newly published release can take a moment to appear on PyPI. Wait and retry, or publish version '99.99.99' before registering it
```

On a version 404 it probes the package-level endpoint
(`/pypi/{name}/json`, `/{name}`) with a `HEAD` to tell the two apart,
and reports 429/5xx as transient rather than "not found". `HEAD` so it
reads a status without pulling the whole packument. The probe carries
its own 3s deadline: it only refines the error message, so a hung probe
must not stretch the validator past the ~10s-per-registry budget the
publish path assumes. Same probe-and-classify shape as the existing
cargo validator.

The fetch is split into `validatePyPIPackage` / `validateNPMPackage`
behind `export_test.go` so the branches are testable with `httptest`,
the same seam cargo uses.

### Testing
- [x] hermetic `httptest` for the status matrix (version-missing,
package-missing, 5xx, 429, inconclusive probe, positive path, scoped
npm); the mocks pin the expected method per endpoint (`GET` fetch,
`HEAD` probe)
- [x] hermetic deadline test: a hung probe is cut off at ~3s and
reported as inconclusive, not "not found"
- [x] existing live package tests still pass, now also hitting the HEAD
probe; on a live 429/5xx they now `t.Skip` as inconclusive instead of
flaking (deliberate: CI runs these against the real registries with no
short-mode gating)
- [x] `gofmt` / `go vet` / `golangci-lint` clean

Out of scope: auto-retry for the propagation race, and SSRF
redirect-pinning parity for the pypi/npm clients (pre-existing, shared
with nuget).
2026-07-12 15:24:34 -04:00
..
cargo.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
cargo_internal_test.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
cargo_test.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
export_test.go fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411) 2026-07-12 15:24:34 -04:00
mcpb.go security: fix open redirect and add small hardening (#1227) 2026-04-29 19:14:00 -04:00
mcpb_test.go Make mcpb package version optional and fix schema validation (#686) 2025-10-17 01:35:29 +03:00
mcpname.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
mcpname_internal_test.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
npm.go fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411) 2026-07-12 15:24:34 -04:00
npm_test.go fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411) 2026-07-12 15:24:34 -04:00
nuget.go fix(validators): harden mcp-name matching (PyPI/NuGet anchoring, comment-form safe) + cargo follow-ups (#1331) 2026-06-05 02:28:41 -04:00
nuget_test.go Fix NuGet.org base URL default, improve API integration (#813) 2025-12-09 07:19:38 -08:00
oci.go fix(validators/oci): fail closed on upstream rate limiting (#1281) 2026-05-12 16:59:59 -04:00
oci_test.go feat(oci): add support for Quay.io registry (#1150) 2026-04-24 06:11:46 -04:00
pypi.go fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411) 2026-07-12 15:24:34 -04:00
pypi_test.go fix(validators): distinguish a missing package from a missing version on PyPI/NPM (#1411) 2026-07-12 15:24:34 -04:00
testutils_test.go Fix NuGet.org base URL default, improve API integration (#813) 2025-12-09 07:19:38 -08:00