Repository navigation
Description
Summary
Under npm trusted publishing (OIDC), changeset publish runs with no auth token, because an _authToken in .npmrc makes npm skip its OIDC exchange. With no token, the pre-publish npm info check returns 404 for every private package, so changesets concludes nothing is published and attempts to publish every package, including unchanged ones whose current version is already on the registry. Those return E403, and instead of being skipped the run crashes:
🦋 error TypeError: Cannot read properties of undefined (reading 'includes')
🦋 error at isAlreadyPublishedError (.../@changesets/cli/dist/changesets-cli.cjs.js:873:17)
🦋 error at internalPublish (.../@changesets/cli/dist/changesets-cli.cjs.js:957:41)
Root cause
In the --json publish path inside internalPublish:
if (json.error.code === "E403" && isAlreadyPublishedError(json.error.summary)) { ... }
// isAlreadyPublishedError(output) => output.includes("cannot publish over the previously published version")With pnpm publish --json (and bun), the error JSON has error.code === "E403" but no error.summary, so isAlreadyPublishedError(undefined) throws. npm does populate summary, so npm-based repos don't crash, but they still report the already-published package as failed rather than skipped, because the message ("...previously published versions: x.y.z") isn't always matched where the check looks. The publish tool is chosen by changesets via package-manager-detector, so which behaviour you get depends on the detected package manager rather than anything the user controls.
When this happens
This only shows up with npm trusted publishing, which is still an uncommon setup, so most workflows never reach this path. But for a repo that does use it, the tokenless publish means the npm info precheck can never see private packages, so changesets re-attempts already-published versions on every release. Any release that leaves at least one package unchanged (its version already on npm) will hit the failing E403 path.
Reproduction
- pnpm (or bun) workspace with private scoped packages, publishing via npm trusted publishing (OIDC, no token present at publish time).
- A release where at least one package is unchanged and its current version is already on npm.
pnpm changeset publishcrashes on the first already-published package.
Workaround
For anyone hitting this before it's fixed: we added a step that runs before changeset publish, while a read token is still available. It checks each workspace package's current version against the registry and sets private: true on the ones that are already published. changesets skips private packages, so changeset publish then only attempts the genuinely new versions. The read token is removed again before the publish step, so the actual publish still happens tokenless via OIDC. The package.json edits are made in the CI checkout and never committed. This sidesteps the crash entirely and has the side benefit of not re-attempting every unchanged package on each release.
Proposed fix
Make isAlreadyPublishedError null-safe and have it check all the fields the message might land in across package managers:
function isAlreadyPublishedError(...parts) {
return parts.filter(Boolean).join("\n").includes("cannot publish over the previously published version");
}
// call: isAlreadyPublishedError(json.error.summary, json.error.detail, stderr.toString())It would also help to document that trusted publishing leaves the npm info precheck unauthenticated, since the tokenless read is a consequence of the OIDC requirement.
Environment: @changesets/[email protected], npm trusted publishing (OIDC), pnpm 11.6 / bun 1.2.
Activity
cschanhniem commentedon Jun 18, 2026
We hit this exact crash in our CI pipeline. The
error.summarybeing undefined with pnpm/bun publish --json is what makes it so confusing — the error code isE403but the null-safety check isn't there.Your workaround is clever (setting
private: truepre-publish), but I want to suggest a simpler approach: if you set theNPM_TOKENenv var to an empty string beforechangeset publish(rather than having it absent entirely), npm/pnpm with OIDC will still use the tokenless path but changesets' pre-checknpm infocalls will gracefully 404 with a readable error instead of crashing.For the actual fix, I'd also suggest checking
stderroutput inisAlreadyPublishedError. With pnpm --json, theE403body sometimes has the "previously published" message in a different field thansummary— I've seen it land inerror.detailor even in raw stderr depending on the version:The broader issue of OIDC +
npm infoprechecks returning 404 for private packages is harder to fix, but at minimum the crash should be a clean skip.ci: switch release workflow to npm Trusted Publishing (OIDC)
chore(renovate): track the npm version pinned in the release workflow
chore(renovate): track the npm version pinned in the release workflow
fix(release): pin npm to v11 to unbreak changeset publish (#7349)
fix(release): pin npm to v11 to unbreak changeset publish (#7350)
ci: harden npm trusted publishing and surface provenance (#493)
feat(release): publish to npm via trusted publishing (OIDC)
chore: fix release by useing `next` version of changeset (SchwarzIT#5841