Repository navigation
npm: version lookup returns 502 - #419
Conversation
Looking up a specific version will trigger a 502 instead of return the version metadata.
andrew
left a comment
There was a problem hiding this comment.
The new version lookup path needs to apply cooldown consistently with package metadata and tarball downloads.
| } | ||
| var out bytes.Buffer | ||
| h.writeNPMVersion(&out, packageName, version, body) | ||
| return out.Bytes(), nil |
There was a problem hiding this comment.
This single-version response returns before cooldown filtering. I reproduced it through Routes() with a seven-day cooldown and a version published one hour ago: /demo hides 2.0.0 and sets latest to 1.0.0, but /demo/latest and /demo/2.0.0 both return HTTP 200 with 2.0.0. Following its rewritten tarball URL then returns 404 because the download path enforces cooldown. Apply cooldown to explicit version lookups and resolve tags consistently with the filtered package metadata, with handler-level regression tests.
There was a problem hiding this comment.
Thanks, my bad. Tested it with default cooldown set to 7d and looked up @babel/core 8.0.7 (published five days ago). 8.0.6 works just fine, so does latest (returns 8.0.6)
$ curl -sS 'http://localhost:8080/npm/https://github.com/babel%2Fcore/8.0.7' | jq
{
"error": "package not found"
}
There was a problem hiding this comment.
Actually, "package not found" is rather misleading here - the package is found, just the version falls under the cooldown policy. Let me reword that.
Also, npm itself has a different copy for non-existent versions (the cooldown-masked version is similar to a non-existent one)
$ curl -s https://registry.npmjs.org/@babel%2Fcore/8.0.8
"version not found: 8.0.8"
There was a problem hiding this comment.
OK, addressed the copy in the latest commit.
tested (set default cooldown to 7d and 8.0.7 is released four days ago or something): ``` $ curl -sS 'http://localhost:8080/npm/@babel%2Fcore/8.0.7' | jq { "error": "package not found" } ```
andrew
left a comment
There was a problem hiding this comment.
The cooldown issue from #419 (comment) is resolved. Version and tag lookups now use filtered package metadata, with HTTP regression coverage.
Looking up a version (latest or e.g. 4.18.1) returns a 502, because it mistreats the slash in
lodash/latestas a namespace separator and escapes it.With this PR in place: