fix: log oidc failures at warn level - #9924
Open
lazerg wants to merge 2 commits into
Open
Conversation
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.
What / Why
When a trusted publish fails, npm falls back to the existing auth and the user only sees
ENEEDAUTH. The reason the OIDC flow gave up is logged atverbose, so nothing shows at the default log level and there is no hint thatNPM_ID_TOKENwas even picked up. Finding out takes a rerun at a higher log level.These failure paths now log at
warn: the two id_token fetch failures from GitHub, the token exchange request error, the missing token in the exchange response, the provenance auto-enable failure, and the outer catch.warnrather thanerrorbecause publishing still goes ahead on whatever auth was already configured, so none of these are fatal. The twoSkipped because ...messages stay atsilly, since running outside a trusted publishing setup is not a failure and should stay quiet.One consequence worth calling out: a workflow that sets
id-token: writefor provenance but has no trusted publishing configured for the package will now see the exchange 404 as a warning on an otherwise successful publish. Happy to narrow it to theNPM_ID_TOKENcase if you would rather keep that quiet. The message wording is left alone to keep the diff to the levels.Testing
The existing OIDC cases in
test/lib/commands/publish.jsalready assert these exact log lines, so their expected level moved fromverbosetowarn. One case is added at the default log level, which is the part the issue is actually about: it fails onlatestbecause nothing reaches stderr at all.npx tappasses withlib/utils/oidc.jsstill at 100% coverage.References
Fixes #9923