npm tarball metadata lookup tries `/package.json` before `package/package.json`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 22
- Forks
- 10
- Avg merge
- 14h 28m
- Merged PRs (30d)
- 54
Description
Summary
modules/har/pkg/har/push_npm.go:162–168 looks for package.json inside an npm tarball using /package.json first, then falls back to package.json. Standard npm tarball layout is package/package.json, so the common case fails the first attempt and only succeeds on fallback — adds latency, and intermediate error messages confuse users / agents reading stderr.
Suggested fix
Swap the order, or normalize entry names by stripping leading slashes inside readFileFromTarGz:
// try the standard layout first
data, err := readFileFromTarGz(tarPath, "package/package.json")
if err != nil {
// fall back to the legacy layout
data, err = readFileFromTarGz(tarPath, "/package.json")
if err != nil {
return ..., fmt.Errorf("could not find package.json in %s: %w", tarPath, err)
}
}
Or unify by normalizing inside the reader:
// inside readFileFromTarGz: trim leading slash on header.Name
trimmed := strings.TrimPrefix(header.Name, "/")
if trimmed == name { ... }
Acceptance
- Order corrected, or reader normalizes paths.
- Test against a real npm tarball — first attempt succeeds, no fallback log noise.
- Test against a non-standard tarball — fallback path still works.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/har/pkg/har/push_npm.go:162–168 and inspect readFileFromTarGz. Verify the standard package/package.json lookup against a real npm tarball, then confirm that a non-standard tarball still uses the fallback and that no unnecessary fallback error is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 76/100