harness / harness/cli

npm tarball metadata lookup tries `/package.json` before `package/package.json`

Open Beginner friendly
#22 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

beta
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.