Skip to content

fix(ci): fail dist-tag removal step when npm rejects a delete - #984

Closed
kucherenko wants to merge 1 commit into
masterfrom
fix/dist-tag-removal-error-handling
Closed

kucherenko wants to merge 1 commit into
masterfrom
fix/dist-tag-removal-error-handling

Conversation

@kucherenko

@kucherenko kucherenko commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

Found by the first real run of the cleanup workflow (run 33316058708).

The bug

The step chained:

npm dist-tag rm jscpd "$tag" && echo "removed: $tag"

Under set -e, a failing command inside an && list is exempt from exit-on-error. npm returned 403 Forbidden for all three tags, no removed: line was ever printed, and the step still reported success — a cleanup workflow that silently does nothing is worse than one that fails.

The fix

Explicit if/else, a failed flag, and a non-zero exit that explains the cause.

Why the 403 (not a permissions problem)

The same token successfully deprecated 147 versions in the same run, so it has package write access. npm gates dist-tag deletion behind interactive 2FA and rejects token auth for it — consistent with the EOTP the same command produces from a laptop. Tag removal therefore has to be done from a terminal:

npm dist-tag rm jscpd prerelease
npm dist-tag rm jscpd canary
npm dist-tag rm jscpd rc

The failure message now says exactly that, so the next person doesn't have to rediscover it.


This change is Reviewable

The step chained 'npm dist-tag rm ... && echo removed', and under set -e a
failing command inside an && list is exempt from exit-on-error. Its first
run turned three 403 Forbidden responses into a green step that reported
having removed nothing.

Use an explicit if/else, track failures, and exit non-zero with a note
that npm rejects dist-tag deletion for token auth on 2FA-enabled accounts
so it has to be done from a terminal.
@kucherenko kucherenko closed this Aug 30, 2026
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.

1 participant