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
Summary
modules/har/pkg/har/push_npm.go:162–168looks forpackage.jsoninside an npm tarball using/package.jsonfirst, then falls back topackage.json. Standard npm tarball layout ispackage/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:Or unify by normalizing inside the reader:
Acceptance