Skip to content

fix(doctor): skip npm audit and explain when no package-lock.json (#36893)#36901

Closed
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:auto-fix-36893
Closed

fix(doctor): skip npm audit and explain when no package-lock.json (#36893)#36901
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:auto-fix-36893

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Summary

Fixes hermes doctor reporting un-actionable npm-vulnerability warnings on Windows native (and any Hermes-managed) installs that ship agent-browser vendored under node_modules/ without a package-lock.json.

When the lockfile is missing the doctor now:

  1. Skips the npm audit call (it cannot be safely remediated anyway)
  2. Prints an info line explaining the audit was skipped
  3. Tells the user that vulnerabilities are managed by the Hermes release pipeline
  4. Tells the user not to run npm audit fix inside the Hermes-managed path

When the lockfile IS present the existing audit logic is unchanged.

Issue

Fixes #36893

Test plan

  • tests/hermes_cli/test_doctor.py::test_run_doctor_skips_npm_audit_when_no_lockfile — new regression test: no lockfile → audit not called, clear info messages emitted
  • tests/hermes_cli/test_doctor.py::test_run_doctor_runs_npm_audit_when_lockfile_present — new regression test: lockfile present → audit runs and surfaces vulnerabilities as before
  • All 61 existing test_doctor.py tests still pass
  • All 70 test_windows_native_support.py + test_windows_compat.py tests still pass
  • All 20 test_security_advisories.py tests still pass

How it was implemented

Followed TDD:

  1. RED — wrote the failing regression test, ran it, saw the audit was being called and the "X npm vulnerabilities" string was being emitted
  2. GREEN — added a 3-line guard in hermes_cli/doctor.py that checks for package-lock.json before invoking npm audit; both new tests pass
  3. REFACTOR — kept the change minimal (one if not ... : ... continue block) and added a comment explaining the Windows-native motivation; no other refactoring needed

Caveats

  • I cannot run a Windows native Hermes install from this Termux/Android environment, so the exact phrasing of the info messages was chosen to match the issue's request ("a doctor remediation message specific to the managed Windows native install") but the underlying logic is platform-agnostic.
  • The fix does not change behavior for installs that DO have a package-lock.json (the common case for development checkouts).

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Jun 1, 2026
@alaamohanad169-ship-it alaamohanad169-ship-it marked this pull request as ready for review June 3, 2026 00:00
@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the auto-fix-36893 branch 2 times, most recently from ff700f2 to fb6c0b2 Compare June 4, 2026 23:23
On Windows native installs (and any Hermes-managed install where
agent-browser is vendored without a package-lock.json), `hermes doctor`
was reporting phantom 'X npm vulnerabilities' and telling users to run
`npm audit fix` inside the Hermes-managed directory in %LOCALAPPDATA%.

That fix path is un-actionable:
- `npm audit fix` requires a lockfile to safely update
- The path is Hermes-managed; users should not hand-edit it
- Vulnerabilities in vendored deps are addressed by the Hermes release
  pipeline, not by individual user action

Now doctor checks for package-lock.json before running the audit. When
it's missing, the audit is skipped and three info lines explain:
1. why the audit was skipped (no package-lock.json)
2. that vulnerabilities are managed by the release pipeline
3. that users should not run `npm audit fix` inside that path

Regression tests cover both the no-lockfile (skip) and lockfile-present
(run normally) paths. Closes NousResearch#36893.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows native: hermes doctor reports agent-browser npm vulnerabilities but package has no lockfile for audit

2 participants