Skip to content

Keep registry URLs out of npm lockfiles - #2719

Merged
DariuszPorowski merged 1 commit into
v0.62from
kachawla-npm-lockfile-omit-registry-resolved
Oct 28, 2026
Merged

DariuszPorowski merged 1 commit into
v0.62from
kachawla-npm-lockfile-omit-registry-resolved

Conversation

@kachawla

@kachawla kachawla commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Stop npm from writing registry download URLs into package-lock.json, and regenerate the lockfiles once without them.

Reason for change

npm records each package's full download URL in the lockfile resolved field, using whatever registry the author installed from. When someone installs through a private registry, those URLs get committed. #2698 landed 214 of them on v0.61. That broke Dependabot (private_source_authentication_failure) and the upmerge to edge, and it took #2709, #2710, and #2713 to clean up by hand.

This PR sets npm's omit-lockfile-registry-resolved option, which makes npm create lockfiles without a resolved key for registry dependencies. Package versions and integrity hashes are still recorded, so installs stay pinned and verified. npm fetches each package from whatever registry is configured at install time.

npm reads .npmrc per project, so the file goes next to each package.json rather than at the repo root. It only sets this option. It does not set registry.

Dependabot behavior with the setting will be confirmed on the next Dependabot run after this merges. #2720 adds a CI check that fails on non-npmjs registry URLs in lockfiles.

How to test

  • Lockfile diff: only resolved lines are removed (644 total). Package names, versions, and integrity values are identical before and after for every lockfile. Regenerated with npm install --package-lock-only (npm 11) from each project folder.
  • npm ci in playwright/ passes. The Build samples workflow on this PR runs the Docker builds for samples/demo/ and samples/dapr/nodeapp/, which run npm ci / npm install against registry.npmjs.org.

File change summary

File Summary of change
playwright/.npmrc, samples/demo/.npmrc, samples/demo/client/.npmrc, samples/dapr/nodeapp/.npmrc New. Set omit-lockfile-registry-resolved=true.
playwright/package-lock.json, samples/demo/package-lock.json, samples/demo/client/package-lock.json, samples/dapr/nodeapp/package-lock.json Regenerated. resolved lines removed, nothing else changed.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the lockfile registry URL cleanup and validation changes.

No open issues 🎉

3 files not reviewed
  • playwright/package-lock.json: Generated file
  • samples/dapr/nodeapp/package-lock.json: Generated file
  • samples/demo/client/package-lock.json: Generated file
What changed in this PR

This PR helps prevent private npm registry URLs from entering lockfiles, avoiding the Dependabot authentication failures and upmerge conflicts seen in earlier updates.

Changes:

  • Adds project-level npm settings to omit registry download URLs from lockfiles.
  • Removes existing resolved URLs while preserving package versions and integrity hashes.
  • Adds validation for non-npmjs HTTP(S) download hosts and Azure Artifacts feed references, running on pull requests and pushes targeting edge and v*.
File Description
samples/​demo/​client/​package-lock.json Removes registry download URLs from client dependencies.
samples/​demo/​client/​.npmrc Enables URL omission for the demo client.
samples/​demo/​.npmrc Enables URL omission for the demo server.
samples/​dapr/​nodeapp/​package-lock.json Removes registry download URLs from Dapr sample dependencies.
samples/​dapr/​nodeapp/​.npmrc Enables URL omission for the Dapr Node.js sample.
playwright/​package-lock.json Removes registry download URLs from test dependencies.
playwright/​.npmrc Enables URL omission for the Playwright project.
.github/​workflows/​validate-lockfiles.yaml Runs lockfile validation in CI.
.github/​scripts/​validate_lockfiles.py Checks tracked lockfiles for disallowed registry references.

Review effort: Balanced

@kachawla
kachawla marked this pull request as ready for review October 27, 2026 19:58
@kachawla
kachawla requested review from a team as code owners October 27, 2026 19:58
nicolejms
nicolejms previously approved these changes Oct 27, 2026

@DariuszPorowski DariuszPorowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now we should target 0.62/edge - 0.61 is not relevant anymore

Add an .npmrc with omit-lockfile-registry-resolved=true next to each
npm project so npm stops writing the registry download URL into
package-lock.json. Lockfiles then don't depend on whichever registry
the author installed from, and installs use the configured registry.

Regenerate each lockfile with npm install --package-lock-only. The only
change is the removal of the resolved lines; package versions and
integrity hashes are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
@kachawla
kachawla changed the base branch from v0.61 to edge October 27, 2026 21:57
@kachawla
kachawla dismissed nicolejms’s stale review October 27, 2026 21:57

The base branch was changed.

@kachawla
kachawla force-pushed the kachawla-npm-lockfile-omit-registry-resolved branch from 6a803b0 to 0be4e95 Compare October 27, 2026 21:57
@kachawla

Copy link
Copy Markdown
Member Author

I think now we should target 0.62/edge - 0.61 is not relevant anymore

@DariuszPorowski updated

@DariuszPorowski
DariuszPorowski changed the base branch from edge to v0.62 October 28, 2026 04:23
@DariuszPorowski
DariuszPorowski merged commit 2d0d0ef into v0.62 Oct 28, 2026
15 of 16 checks passed
@DariuszPorowski
DariuszPorowski deleted the kachawla-npm-lockfile-omit-registry-resolved branch October 28, 2026 04:24
DariuszPorowski pushed a commit to radius-project/bicep-types-aws that referenced this pull request Oct 29, 2026
## Summary

Adds `src/aws-type-generator/.npmrc` with
`omit-lockfile-registry-resolved=true` and regenerates
`package-lock.json` once so it no longer stores registry download URLs.

## Reason for change

npm writes each package's full download URL into the lockfile's
`resolved` fields, using whatever registry the author installed from. If
someone runs `npm install` against a private mirror, those mirror URLs
get committed. That happened in radius-project/samples#2698, which
committed 214 private registry URLs. It broke Dependabot
(`private_source_authentication_failure`) and an upmerge, and took
radius-project/samples#2709, radius-project/samples#2710, and
radius-project/samples#2713 to clean up by hand.


[`omit-lockfile-registry-resolved`](https://docs.npmjs.com/cli/v10/using-npm/config#omit-lockfile-registry-resolved)
tells npm to leave out the `resolved` key for registry dependencies.
Versions and `integrity` hashes stay, and npm resolves packages from
whatever registry is configured at install time. Non-registry entries
keep their `resolved` value, so the `bicep-types` file link is
unchanged.

This lockfile only has public registry URLs today, so this is
preventive. It mirrors radius-project/samples#2719.

The one-time lockfile change removes 377 `resolved` lines and nothing
else: no version or integrity changes.

## How to test

1. Check the lockfile diff is only `resolved` removals:
   ```bash
git show origin/main:src/aws-type-generator/package-lock.json >
/tmp/before.json
diff <(jq -S 'del(.. | .resolved?)' /tmp/before.json) <(jq -S .
src/aws-type-generator/package-lock.json)
   ```
   Expected: no output.
2. Install and test the way CI does:
   ```bash
   git submodule update --init --recursive
   (cd bicep-types/src/bicep-types && npm ci && npm run build)
   cd src/aws-type-generator && npm ci && npm run build && npm test
   ```
Expected: install succeeds, tests pass, and `package-lock.json` is not
modified.
3. Run `npm install` in `src/aws-type-generator` after a dependency
change. Expected: no `resolved` fields are added for registry packages.

## File change summary

| File | Summary of change |
| ---- | ----------------- |
| `src/aws-type-generator/.npmrc` | New. Sets
`omit-lockfile-registry-resolved=true`. |
| `src/aws-type-generator/package-lock.json` | Regenerated. Removes 377
registry `resolved` URLs; no other changes. |

Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants