Skip to content

percent-encode npm releaser names in Maintainer changes section#14638

Open
v-HaripriyaC wants to merge 9 commits intomainfrom
chp/brokendownlinks-npm-yarn
Open

percent-encode npm releaser names in Maintainer changes section#14638
v-HaripriyaC wants to merge 9 commits intomainfrom
chp/brokendownlinks-npm-yarn

Conversation

@v-HaripriyaC
Copy link
Copy Markdown
Contributor

@v-HaripriyaC v-HaripriyaC commented Apr 7, 2026

What are you trying to accomplish?

Fixes #14595 — The Maintainer changes section in Dependabot PR bodies for npm dependencies can generate a broken Markdown link if the npm releaser name contains spaces (or other URL-unsafe characters), such as in the case of "GitHub Actions".

Previously, the link for the releaser in the PR body was constructed like:

Markdown
This version was pushed to npm by [GitHub Actions](https://www.npmjs.com/~GitHub Actions), ...
This link is broken due to the unencoded space in the URL, which is invalid in Markdown and web standards.

What changed?

npm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rb: The maintainer_changes method now uses a new encode_npm_releaser helper. This percent-encodes the npm releaser name according to RFC 3986 before interpolating it into the npmjs.com profile URL — e.g., "GitHub Actions" becomes "GitHub%20Actions" in the URL, producing a valid Markdown link. The helper short-circuits for normal usernames (all safe chars) as an optimization.
Spec coverage: Added tests using a realistic fixture to confirm spaces and other special characters are encoded, and the Markdown link is syntactically valid.
How will you know you've accomplished your goal?

New and existing specs pass, explicitly verifying %20 encoding for spaces in npm releaser profile links.
In real Dependabot PRs (e.g., npm-package-json-lint 9.0.0 → 10.0.0), the Maintainer changes section now shows a correctly formed Markdown link. Note: the target npm profile may still 404 for bot releasers — this is upstream behavior outside Dependabot's control.
Anything to highlight for reviewers?

Encoding leverages RFC 3986 compliance via Ruby stdlib. Display text is intentionally left unencoded.
The npmjs.com URL may 404 for certain bot releasers — this fix only ensures the Markdown and URI are syntactically valid.
Checklist

Tests and linters pass
New tests added for the space-in-releaser-name scenario
Clear commit messages
Detailed PR description provided
Code is documented and easy to understand

@v-HaripriyaC
Copy link
Copy Markdown
Contributor Author

@kbukum1 none of this PR checks failing are related to this PR. below is the info

smoke-npm.yaml Docker build failed — curl downloaded corrupt/empty git-shim tarball ❌ Infrastructure flakiness
smoke-npm-yarn.yaml Live npm version 3.6.19 doesn't match fixture expectation ❌ Registry version drift
smoke-npm-version-multidir.yaml Unexpected Install script changessection in PR body ❌ Registry snapshot staleness

@v-HaripriyaC
Copy link
Copy Markdown
Contributor Author

these are pre-existing smoke flakiness failures unrelated to this change

@v-HaripriyaC v-HaripriyaC requested a review from kbukum1 April 13, 2026 17:57
@v-HaripriyaC v-HaripriyaC marked this pull request as ready for review April 13, 2026 17:57
@v-HaripriyaC v-HaripriyaC requested a review from a team as a code owner April 13, 2026 17:57
Copilot AI review requested due to automatic review settings April 13, 2026 17:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes broken Markdown links in the Maintainer changes section for npm dependencies when the npm releaser name contains spaces or other URL-unsafe characters by percent-encoding the releaser name before building the npmjs.com profile URL.

Changes:

  • Add a helper to percent-encode npm releaser names used in npm profile links.
  • Add/extend spec coverage with a realistic npm registry response fixture to verify encoding behavior.
  • Adjust registry URL handling/spec around trailing slashes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
npm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rb Encode npm releaser in maintainer profile URLs; adjust registry URL normalization logic.
npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb Add coverage for maintainer link encoding; update registry URL trailing-slash scenario.
npm_and_yarn/spec/fixtures/npm_responses/npm-package-json-lint.json Add fixture with a releaser name containing spaces to reproduce/verify the issue.

@v-HaripriyaC v-HaripriyaC changed the title Fix for the npm upgrade with broken links - 404 error percent-encode npm releaser names in Maintainer changes section Apr 13, 2026
@v-HaripriyaC
Copy link
Copy Markdown
Contributor Author

@kbukum1 The failing smoke e2e jobs (smoke-npm.yaml, smoke-npm-yarn.yaml, smoke-npm-version-multidir.yaml) are pre-existing failures on main caused by live npm registry version drift (fixture snapshots are stale). These are not related to the changes in this PR. Verified by checking the same jobs fail on main at commit 20fe02a.

v-HaripriyaC and others added 9 commits April 14, 2026 16:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…4711)

* Initial plan

* Fix percent-encoding issues in npm_and_yarn and bun MetadataFinders

Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/13261c22-8e0e-42fe-a06d-e8a7c3b7ad76

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>

* Address code review: remove private method test from bun spec

Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/13261c22-8e0e-42fe-a06d-e8a7c3b7ad76

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>

* parametric tests added, fixed some edge case as well

* ade sure the fix is for bun

* added some more fixes

* added small fixe

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Co-authored-by: v-HaripriyaC <v-haripriyac@microsoft.com>
@v-HaripriyaC v-HaripriyaC force-pushed the chp/brokendownlinks-npm-yarn branch from d24e7eb to 28fd85a Compare April 15, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken links in Maintainer changes section

3 participants