-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPM: Authentication with private registry fails with ERR_INVALID_AUTH #7759
Comments
Running into the same issue, when using a single private registry in the .npmrc. |
I have the same issue with the same use case |
same here |
1 similar comment
same here |
And here. |
@rickardgranberg Nice research! I think all would be needed here would to disable the logic to detect a global registry to apply only when not using NPM >= v8? Could you try making that change and see if that works? |
Actually, maybe scoping all auth related configurations is better, even if it's the global scope. I don't think that would break anything for other package managers. |
I created a potential fix for this but I'm not able to validate it. I created a test feed with the same configuration reported here, and Dependabot is working just fine for me. I understand the theoretical issue explained, but I'm not able to recreate the conditions for it to trigger. Can you show the logs of a broken update? |
I get those logs from our CI:
The content of the .npmrc file looks like:
Does that help you? |
Oh, that does help, let me do an additional check. |
Nah, it insists on just working no matter what I do. I'm a bit lost here. I also tried to reproduce via https://github.com/dependabot/cli so that I can debug what |
Is someone running into this on GitHub.com rather than on Azure Devops? |
I played a round with the Dependabot CLI as well, but it seems the yaml format doesn't allow me to provide a token for the git repository (that is also hosted in a private Azure space). Ideally I would just point it to a repo that I already checked out, but this also doesn't seem possible with the yaml format. |
Did you try the In any case, I was just able to verify that #8453 indeed fixes the issue! 🎉 EDIT: In case it's useful to anyone, I needed to include a |
We've been looking for explanations to all this. The reason this does not happen in I was able though to use the CLI with an input file including this credentials-metadata:
- type: npm_registry
registry: <feed_url>
replaces-base: true
token: <base64representation-of-username:pat> to simulate what goes on in Azure Devops in this issue reproduced exactly as reported, and gets fixed by #8453. |
This fix is now deployed! Once this is picked up by https://github.com/tinglesoftware/dependabot-azure-devops, please do confirm that the issue is now gone 🙏. |
Is there an existing issue for this?
Package ecosystem
npm
Package manager version
9.5.1
Language version
No response
Manifest location and content before the Dependabot update
No response
dependabot.yml content
version: 2
registries:
npm-internal:
type: npm-registry
url: pkgs.dev.azure.com/org/project/_packaging/registry/npm/registry
token: ${{NPM_PAT}}
replaces-base: true
updates:
- package-ecosystem: 'npm'
directory: '/'
registries:
- npm-internal
schedule:
interval: 'weekly'
Updated dependency
No response
What you expected to see, versus what you actually saw
This problem started happening when using NPM version 8 or newer.
In our configuration, we're using Azure Artifacts as the only registry, with upstream feeds to npmjs et.al.
Our .npmrc looks like:
This also means that every package in
package-lock.json
will have the above registry as theresolved
URL.From what I can deduce by looking at the npmrc_builder.rb file in dependabot-core, this means that this registry will be classified as a
global
registry, see:dependabot-core/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb
Line 84 in f9754d4
This in turn leads to this part of the code
dependabot-core/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb
Line 165 in f9754d4
.npmrc
:This is a problem, because since NPM v8, all auth-related values need to be scoped, see: https://docs.npmjs.com/cli/v9/configuring-npm/npmrc?v=true#auth-related-configuration
A correct
.npmrc
needs to look like:Native package manager behavior
No response
Images of the diff or a link to the PR, issue, or logs
No response
Smallest manifest that reproduces the issue
No response
The text was updated successfully, but these errors were encountered: