Fix percent-encoding gaps in npm_and_yarn and bun MetadataFinders#14711
Merged
v-HaripriyaC merged 7 commits intochp/brokendownlinks-npm-yarnfrom Apr 14, 2026
Merged
Conversation
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>
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>
Copilot
AI
changed the title
[WIP] Fix percent-encoding for registry URLs in MetadataFinder
Fix percent-encoding gaps in npm_and_yarn and bun MetadataFinders
Apr 13, 2026
kbukum1
approved these changes
Apr 13, 2026
d24e7eb
into
chp/brokendownlinks-npm-yarn
54 of 57 checks passed
v-HaripriyaC
pushed a commit
that referenced
this pull request
Apr 15, 2026
…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
pushed a commit
that referenced
this pull request
Apr 15, 2026
…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
pushed a commit
that referenced
this pull request
Apr 15, 2026
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #14638 removed the deprecated
URI::DEFAULT_PARSER.escapefromnpm_and_yarnMetadataFinder'sdependency_url, but leftnormalize_registry_url(called viaconfigured_registry_from_credentials) without any space-encoding. Credentials with raw spaces in their registry URL — a supported, tested scenario — would produce invalid HTTP requests on the credentials path. ThebunMetadataFinder also had the identical unencodedmaintainer_changesbug that #14638 fixed for npm_and_yarn.Changes
npm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rbnormalize_registry_urlnow strips whitespace and encodes spaces as%20, matchingRegistryFinder#prepare_registry_url:bun/lib/dependabot/bun/metadata_finder.rbrequire "cgi",CHARS_REQUIRING_ENCODINGconstant, andencode_npm_releaserprivate helper (identical to the npm_and_yarn fix)maintainer_changesto useencode_npm_releaserfor the URL portion; display text intentionally left unencodednormalize_registry_urlspace-encoding fix applied for consistency (forward-compatible with eventualURI::DEFAULT_PARSER.escaperemoval)Tests & fixtures
npm_and_yarnspec: newdependency_urltest for areplaces-basecredential with spaces in the registry URLbunspec: newmaintainer_changestest asserting%20-encoded link when releaser name contains spacesbun/spec/fixtures/npm_responses/npm-package-json-lint.jsoncopied from npm_and_yarn to back the new bun fixture testChecklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.launchpad.net/usr/bin/add-apt-repository add-apt-repository -y ppa:git-core/ppa grep rity.crt -q la/emSign_Root_CA_-_G1.crt e u3_amd64.deb(dns block)ports.ubuntu.com/usr/lib/apt/methods/http /usr/lib/apt/methods/http(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Context
PR #14638 (
chp/brokendownlinks-npm-yarn) correctly removes the deprecatedURI::DEFAULT_PARSER.escapecall fromMetadataFinder#dependency_urland replaces the npm releaser encoding with a proper RFC 3986-compliant helper. However, during review we identified a regression gap:Problem
The
configured_registry_from_credentialsmethod innpm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rbcallsnormalize_registry_url, which does not percent-encode spaces or other unsafe characters. Previously,URI::DEFAULT_PARSER.escapeindependency_urlserved as a safety net for this path.The
RegistryFinderclass handles this correctly viaprepare_registry_urlwhich doesurl&.strip&.gsub(/\s+/, "%20"), butMetadataFinderhas its ownconfigured_registry_from_credentialsthat bypassesRegistryFinderentirely. This path is hit whennew_sourceis nil (dependencies resolved from the default registry) and areplaces-basecredential is configured.Existing specs in
registry_finder_spec.rbprove that credentials with spaces are a supported scenario:Additionally, the
bunecosystem'smetadata_finder.rbhas the same unencodedmaintainer_changesbug that PR #14638 fixes fornpm_and_yarn, but was not addressed.Required Changes
1. Fix
normalize_registry_urlinnpm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rbUpdate
normalize_registry_urlto also strip and encode spaces, matching the behavior ofRegistryFinder#prepare_registry_url:2. Add a test case in
npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rbAdd a test for the
source_url(ordependency_url) path that exercisesconfigured_registry_from_credentialswith a credential containing spaces, verifying that the URL is properly encoded.3. Apply the same
encode_npm_releaserfix tobun/lib/dependabot/bun/metadata_finder.rbThe bun metadata finder at
bun/lib/dependabot/bun/metadata_finder.rbhas the identical bug inmaintainer_changes(lines 30-38):Apply the same pattern used in the npm_and_yarn fix:
require "cgi"at the topCHARS_REQUIRING_ENCODINGconstantencode_npm_releaserprivate helper methodmaintainer_changesto useencode_npm_releaserfor the URL portion4. Fix
normalize_registry_urlinbun/lib/dependabot/bun/metadata_finder.rbtooThe bun metadata finder has the same
normalize_registry_urlthat doesn't encode spaces. Apply the same fix as in npm_and_yarn.5. Add test coverage for bun in
bun/spec/dependabot/bun/metadata_finder_spec.rbAdd similar test cases for the bun ecosystem:
maintainer_changesproperly encodes releaser names with spacesencode_npm_releaserprivate helper6. Add the same npm response fixture for bun tests
Copy or reference the
npm-package-json-lint.jsonfixture so bun tests can verify the maintainer encoding behavior.Important Notes
chp/brokendownlinks-npm-yarnbranch (PR percent-encode npm releaser names in Maintainer changes section #14638's head branch)bunmetadata finder is largely a copy of thenpm_and_yarnone, so the changes should mirror what PR percent-encode npm releaser names in Maintainer changes section #14638 already didURI::DEFAULT_PARSER.escapefrombun/lib/dependabot/bun/metadata_finder.rb'sdependency_url— that should be a separate consideration. Only add the releaser encoding and thenormalize_registry_urlspace-encoding fix.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Can you review the changes?
Assistant:
I'll load the PR review abilities and then gather the necessary context to review this pull request.
Assistant: Now let me check if CI is all green:
Assistant: Here's my review of PR #14638:
PR Summary
percent-encode npm releaser names in Maintainer changes section by @v-HaripriyaC
This pull request was created from Copilot chat.