Skip to content

Conversation

@jakecoffman
Copy link
Member

We are beginning to standardize more on how to define registries by passing the URL when possible.

For NPM-like registries, Dependabot-Core is expecting "registry" which is actually the hostname of the URL. So here we fix up the metadata to give Core what it expects.

Longer term this should live in Core, but this is a good first step.

Copilot AI review requested due to automatic review settings July 16, 2025 19:39
@jakecoffman jakecoffman requested a review from a team as a code owner July 16, 2025 19:39
Copy link
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

This PR addresses an issue where NPM-like registries in Dependabot-Core expect a "registry" field containing the hostname, but the current implementation only provides a URL. The solution extracts the hostname from the URL when the registry field is missing for npm_registry credentials.

  • Adds logic to extract hostname from URL for npm_registry credentials when registry is not provided
  • Moves the URL assignment earlier in the credential processing to ensure it's available for all credential types
  • Includes comprehensive test coverage for the new URL-to-registry conversion functionality

Reviewed Changes

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

File Description
src/updater.ts Implements hostname extraction logic for npm_registry credentials and reorders URL assignment
tests/updater.test.ts Adds test case to verify registry field is correctly populated from URL hostname
Comments suppressed due to low confidence (1)

tests/updater.test.ts:206

  • The test only covers the happy path with a valid URL. Consider adding test cases for edge cases like invalid URLs, URLs without hostnames, or malformed URLs to ensure the try-catch block in the implementation works correctly.
    it('generates credentials metadata with the registry from the URL', () => {

@honeyankit
Copy link
Contributor

@jakecoffman Do we need negative test here?
Consider adding test cases for edge cases like invalid URLs, URLs without hostnames, or malformed URLs to ensure the try-catch block in the implementation works correctly.

Copy link
Contributor

@rickreyhsig rickreyhsig left a comment

Choose a reason for hiding this comment

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

:shipit:

@jakecoffman jakecoffman enabled auto-merge (squash) July 16, 2025 20:07
@jakecoffman jakecoffman merged commit 9d2ccea into main Jul 16, 2025
9 checks passed
@jakecoffman jakecoffman deleted the handle-npm-url-without-registry branch July 16, 2025 20:09
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