Skip to content

ci(sdk): drop registry-url so npm actually uses OIDC to publish - #35

Merged
bytesbrains merged 1 commit into
mainfrom
ci/fix-npm-oidc-authtoken
Jul 28, 2026
Merged

ci(sdk): drop registry-url so npm actually uses OIDC to publish#35
bytesbrains merged 1 commit into
mainfrom
ci/fix-npm-oidc-authtoken

Conversation

@nandal

@nandal nandal commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

The first real publish (run 30397586602) passed every gate, built the correct tarball, and then failed at the publish step:

npm error code E404
npm error 404 Not Found - PUT https://registry.npmjs.org/@bytesbrains%2fmaktub-sdk

Nothing was published — the registry still holds three versions and 0.1.0-dev.4 is untouched and reusable.

The trusted-publisher config was not at fault. registry-url makes setup-node write an .npmrc containing //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} and export NODE_AUTH_TOKEN as the literal placeholder XXXXX-XXXXX-XXXXX-XXXXX when no token is supplied. npm saw a configured credential, used it instead of attempting the OIDC exchange, and the registry rejected the garbage token.

npm returns E404 rather than E401 so it doesn't leak which private packages exist — which is why a shadowed credential reads like a misconfigured publisher and sends you looking in the wrong place.

Change summary

  • Removed registry-url from setup-node, with a comment explaining why it must stay removed so nobody "fixes" it back. npm falls back to its default registry — the same host — and authenticates via OIDC.
  • Added an "OIDC must be available and unshadowed" gate that fails early and by name on both silent failure modes: no OIDC token endpoint, or an _authToken configured in any npmrc npm reads. This class of break should never again surface as an opaque E404 after the artifact has been built.

Tests

Diagnosed on a real runner rather than assumed. A throwaway branch printed the runner's actual state, and with registry-url absent:

ACTIONS_ID_TOKEN_REQUEST_URL set? YES
NODE_AUTH_TOKEN value: <unset>
--- npmrc (none) ---
(no user npmrc)

That also settles a red herring worth recording: GitHub does not list Id-token in the "GITHUB_TOKEN Permissions" log group even when it is granted. That group showed only Contents: read / Metadata: read on both runs, which initially looked like the permission had been dropped. It hadn't — the env var proves OIDC was available all along. The new gate checks the env var, not the log group.

YAML re-validated; 13 steps, permissions unchanged (contents: read, id-token: write).

Authentication is still only genuinely exercised on a real publish, so the proof is the next non-dry run.

Risk

Low. Confined to the publish workflow, which is inert until dispatched. The failure mode being fixed leaves nothing behind — the previous attempt wrote nothing to the registry.

Backwards-compat

None affected. No source file, published artifact, or other workflow is touched.

Privacy copy

No user-facing privacy copy.

🤖 Generated with Claude Code

The first real publish (run 30397586602) passed every gate and then failed:

  npm error code E404
  npm error 404 Not Found - PUT https://registry.npmjs.org/@bytesbrains%2fmaktub-sdk

Nothing was published; 0.1.0-dev.4 is untouched and reusable.

The cause was not the trusted-publisher config. `registry-url` makes setup-node
write an .npmrc containing //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
and export NODE_AUTH_TOKEN as the literal placeholder XXXXX-XXXXX-XXXXX-XXXXX
when no token is supplied. npm saw a configured credential, used it instead of
attempting the OIDC exchange, and the registry rejected the garbage token. npm
reports E404 rather than E401 so it does not leak which private packages exist,
which makes a shadowed credential read like a misconfigured publisher and sends
you looking in the wrong place.

Confirmed on a runner rather than assumed: with registry-url absent,
ACTIONS_ID_TOKEN_REQUEST_URL is set, NODE_AUTH_TOKEN is unset and no user npmrc
is written. That also settles a red herring worth recording — GitHub does NOT
list Id-token in the "GITHUB_TOKEN Permissions" log group even when it is
granted, so that group cannot be used to check whether OIDC is available. The
env var can.

Dropping registry-url leaves npm on its default registry, which is the same
host, and lets it authenticate via OIDC.

Adds a gate that names both silent failure modes up front — no OIDC endpoint, or
an _authToken configured anywhere npm reads — so this class of break can never
again surface as an opaque E404 after the artifact has already been built.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@wrokin

wrokin Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🤖 wrokin code review

Summary: Removes registry-url to prevent OIDC shadowing and adds a pre‑publish OIDC health check.

No high‑signal issues (bug/security/correctness) identified in this diff.

Model: deepseek/deepseek-v4-pro · your key, your model (BYOK)

@wrokin

wrokin Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🤖 wrokin security audit

No security-relevant findings in this diff. The changes remove an incorrect registry-url that was shadowing OIDC trusted publishing and add a preflight check to catch misconfigurations before publish — both are security improvements, not vulnerabilities.

Model: deepseek/deepseek-v4-pro · your key, your model (BYOK)

@wrokin

wrokin Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🛡️ wrokin security hunter

No vulnerabilities were proven in this pull request — the hunter found nothing it could exploit and prove by execution.

Advisory only — this check never blocks your PR.

@bytesbrains
bytesbrains merged commit a93101a into main Jul 28, 2026
10 checks passed
@bytesbrains
bytesbrains deleted the ci/fix-npm-oidc-authtoken branch July 28, 2026 20:52
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.

2 participants