[BUG] OIDC failures aren't logged by default
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
If there's a problem exchanging an OIDC token during trusted publishing, it doesn't get logged by default, I just get:
npm error code ENEEDAUTH
npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
npm error need auth You need to authorize this machine using `npm login`
I can't tell from this if it even picked up my NPM_ID_TOKEN.
Only after I used --loglevel=silly did I see:
npm http fetch POST 404 https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/@jcoreio%2ftoolchain 845ms
npm verbose oidc Failed token exchange request with body message: OIDC token exchange error - package not found
Expected Behavior
All OIDC failure messages in https://github.com/npm/cli/blob/latest/lib/utils/oidc.js are logged at error or warn level
(I'll be happy to make a PR if you agree)
Steps To Reproduce
- Set
NPM_ID_TOKENto an OIDC token that will error out for some reason (in my case, it had the CircleCI SSH rerun claim) - Run
npm publish(with default log level)
Environment
- npm: 12.0.2
- Node.js: 24.20.0
- OS Name: any
- System Model Name: any
- npm config: default
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/utils/oidc.js, then reproduce the failure by setting NPM_ID_TOKEN and running npm publish at the default log level. Done means every OIDC failure message is visible at error or warn level without requiring --loglevel=silly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- authentication, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100