Skip to content

git pkgs urls can generate invalid URLs from database lookups #239

Closed

Description

@abhinavgautam01

Summary

git pkgs urls can generate invalid registry/download URLs when resolving a plain package name from the database.

Reproduction

go build -o /tmp/git-pkgs .

tmp=$(mktemp -d /tmp/git-pkgs-urls.XXXXXX)
cd "$tmp"

git init --initial-branch=main
git config user.email test@example.com
git config user.name "Test User"

printf '{"dependencies":{"lodash":"^4.17.21"}}\n' > package.json
git add package.json
git commit -m "Add package manifest"

/tmp/git-pkgs init --no-hooks
/tmp/git-pkgs urls lodash -e npm
/tmp/git-pkgs urls lod -e npm

Actual behavior

For lodash, the command uses the version range as if it were an exact tarball version:

download https://registry.npmjs.org/lodash/-/lodash-^4.17.21.tgz

For substring lookup lod, it uses lodash's requirement but builds URLs for lod:

download https://registry.npmjs.org/lod/-/lod-^4.17.21.tgz
purl pkg:npm/lod@^4.17.21

Expected behavior

  • urls lodash -e npm should not generate exact-version tarball URLs from a version range.
  • Plain-name lookup should either require an exact package match or use the matched package name from the database.

Likely cause

lookupPackage falls back to the first substring search result, but returns the original query name instead of the matched result name.

Activity

  1. added
    bug
    on Jun 19, 2026
  2. andrew commented on Jun 19, 2026

    @andrew
    Contributor

    Fix in #240.

    lookupPackage now returns the matched package name (so urls lod resolves to lodash, not lod) and only treats the requirement as a version when it comes from a lockfile or an ecosystem whose manifests pin exact versions (Go, Maven). For a manifest-only match like ^4.17.21 it leaves the version empty, so you get pkg:npm/lodash and no download URL rather than a tarball URL with a caret in it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions