Skip to content

pacquet: publish auth settings are CLI-flag-only where the TypeScript CLI resolves them from config #28

Closed
pnpm/pnpm
#13626

Description

@KSXGitHub

Summary

The TypeScript CLI resolves pnpm publish's auth-related settings through the whole config chain — pnpm-workspace.yaml, the global config.yaml, PNPM_CONFIG_* env vars, and CLI flags. pacquet honors several of them only as CLI flags, so a value set in a config file is silently ignored where pnpm would have used it.

Found while reviewing pnpm/pnpm#13255, which fixes the same class of bug for scope. That PR is one instance; this issue tracks the rest of the cluster.

The criterion here is the TypeScript implementation, not pnpm.io. The docs are known to be incomplete for this surface (scope is honored by the reader and documented nowhere), so "is it documented?" is the wrong question to gate on. The question is: can a value in pnpm-workspace.yaml / config.yaml / PNPM_CONFIG_* reach the behavior in TS? If yes, pacquet must match.

Status of each publish rc option

rcOptionsTypes() in pnpm11/releasing/commands/src/publish/publish.ts:24-39 declares twelve settings. TS resolves every one of them from the config chain. pacquet:

rc option pacquet where
git-checks ✅ config-resolved publish.rs:170 — config.git_checks && !flags.no_git_checks
ignore-scripts ✅ config-resolved publish.rs:287 — flags.ignore_scripts || config.ignore_scripts
unsafe-perm ✅ config-resolved config.unsafe_perm
registry ✅ config-resolved config.registry
otp ⚠️ env only publish.rs:178 — resolve_otp_from_env reads PNPM_CONFIG_OTP, but no config-file source
access ❌ flag only publish.rs:337 — flags.access (+ publishConfig.access fallback)
tag ❌ flag only publish.rs:338 — flags.tag.unwrap_or("latest")
provenance ❌ flag only publish.rs:341 — flags.provenance
publish-branch ❌ flag only publish.rs:81 / used at :169
skip-manifest-obfuscation ❌ flag only publish.rs:73 (already listed in NOT_PORTED)
embed-readme ❌ not implemented already listed in NOT_PORTED
npm-path ❌ absent —

git-checks and ignore-scripts are the proof that the pattern is understood in pacquet: both are TS rc options and both already take a config fallback in the very same function. The others just never got one.

The version command has the same shape (pnpm11/releasing/commands/src/version/index.ts:28-38 declares allow-same-version, commit-hooks, git-checks, git-tag-version, message, sign-git-tag, tag-version-prefix); in pacquet allow_same_version, message, sign_git_tag, tag_version_prefix are flag-only and commit-hooks / git-tag-version are absent. Not auth, but worth folding into the same sweep.

Nuances — read these before implementing

These are the traps. Several are places where a "just add a Config field" fix silently changes behavior.

1. otp has two independent env paths, and pacquet mirrors only one

otp is in npmConfigTypes (npmConfigTypes.ts:47 — otp: [null, String]), so it flows through the generic reader like any other setting: yaml, config.yaml, PNPM_CONFIG_OTP, --otp.

On top of that, TS applies a dedicated overlay — optionsWithOtpEnv in pnpm11/releasing/commands/src/publish/otpEnv.ts, called at publish.ts:235 — that reads PNPM_CONFIG_OTP straight from process.env.

pacquet implements the overlay (pnpm/crates/publish/src/otp_env.rs, resolve_otp_from_env) and nothing else. So adding a config-file source must not disturb the overlay's precedence: an explicit value still wins over the env var.

2. The otp overlay treats an empty string as "not defined" — in both directions

Boolean(opts.otp) || !otp   // empty string is considered "not defined" here
  ? opts
  : { ...opts, otp }

An empty --otp "" is falsy, so it falls through to the env var; an empty PNPM_CONFIG_OTP="" is ignored. pacquet's resolve_otp_from_env already matches this exactly via current_otp.filter(|otp| !otp.is_empty()). Upstream pins the semantics in pnpm11/releasing/commands/test/publish/optEnv.test.ts (4 cases) — port those alongside any change.

3. The otp env overlay does not apply to recursive publish — in either stack, by accident of statement order

In publish.ts, the recursive branch returns at lines 226-233, and optionsWithOtpEnv runs at line 235 — after it. So PNPM_CONFIG_OTP never reaches a recursive publish.

pacquet currently matches this, also by ordering: run_recursive returns at publish.rs:173-176 and resolve_otp_from_env is called at :178.

This is a booby trap. The behavior is load-bearing but is encoded only as "the early return happens to come first" on both sides. Anyone hoisting the OTP resolution earlier — an obvious-looking cleanup — silently changes behavior in one stack. If it is touched, pin it with a test on both sides. (Whether the exclusion is intended upstream is a separate question worth raising; until it changes, pacquet mirrors it.)

4. access — an invalid publishConfig.access is silently ignored, and the config source must slot in before it

const publishConfigAccess = publishedManifest.publishConfig?.access
const access = opts.access ?? (isPublishAccess(publishConfigAccess) ? publishConfigAccess : null)

(batchPublish.ts:215-216, and identically in publishPackedPkg.ts createPublishOptions.) isPublishAccess (publishPackedPkg.ts:205-207) accepts only 'public' / 'restricted'; anything else in publishConfig.access is dropped without an error.

pacquet's resolve_access (pnpm/crates/publish/src/publish_options.rs:92-100) already matches. The trap: a config-file access is part of opts.access, so it must win over publishConfig.access — resolving it as a fallback after publishConfig would invert the precedence.

There is also a guard to preserve: an unscoped package with access === 'restricted' throws ERR_PNPM_UNSCOPED_RESTRICTED (batchPublish.ts:217-219).

5. tag — TS applies the 'latest' default at the use site, pacquet bakes it in early

TS keeps tag optional and defaults where it is consumed: opts.tag ?? 'latest' (batchPublish.ts:238, recursivePublish.ts:122). pacquet collapses it at construction: flags.tag.clone().unwrap_or_else(|| "latest".to_owned()) (publish.rs:338).

That is fine while the flag is the only source. Once a config source is added, an early default erases the distinction between "unset" and "explicitly latest", which is exactly the distinction a flag ?? config ?? default chain needs. Resolve as Option, default last.

6. Do not use "does pacquet's Config have this field?" as the probe

This is the mistake that produced a wrong first answer during the pnpm/pnpm#13255 review. pacquet legitimately implements some rc options as command-level resolution rather than Config fields — resolve_access and resolve_otp_from_env are real, working implementations that a Config-field grep reports as missing. Structural difference is allowed; only observable behavior has to match.

The correct probe is behavioral: can a value set in pnpm-workspace.yaml, the global config.yaml, or PNPM_CONFIG_* reach the behavior? For access / tag / provenance / publish-branch the answer in pacquet is no, and that is the actual bug.

7. Why the existing parity test did not catch any of this

pnpm/crates/config/src/pnpm_default_parity.rs compares pacquet's defaults against pnpm's defaultOptions literal. Only 10 of the 67 npmConfigTypes keys appear in defaultOptions; the other 57 have no automated parity coverage at all. Every setting in this issue lives in that gap, and so did scope.

A test that walks the union of every command's rcOptionsTypes() (116 distinct settings across 45 TS command modules) and asserts each is reachable from config in pacquet would close the hole permanently. That is probably the highest-value item here — more than any individual setting.

8. .npmrc is not a source for any of these — and the auth allowlist is already in sync

readAndFilterNpmrc (pnpm11/config/reader/src/loadNpmrcFiles.ts:454) keeps only keys satisfying isNpmrcReadableKey, i.e. @… / //… prefixed, NPM_AUTH_SETTINGS, or NETWORK_INI_KEYS. None of otp, access, tag, provenance qualify, so pnpm ignores them in an .npmrc and pacquet must too — do not "helpfully" add .npmrc parsing for them.

The credential allowlist itself already matches byte-for-byte between the stacks (ca, cafile, cert, key, registry, _auth, _authToken, _password, email, username — localConfig.ts:107-114 vs pnpm/crates/config/src/config_types.rs:404-415), so there is nothing to fix on that surface.

Suggested order

  1. The rcOptionsTypes() sweep test from nuance 7 — it turns this from a manual audit into a standing guarantee.
  2. access, tag, provenance, publish-branch — add the config source, preserving the precedence in nuances 4 and 5.
  3. otp — add the config-file source alongside the existing env overlay (nuances 1-3).
  4. skip-manifest-obfuscation, embed-readme, npm-path — these are also feature gaps, not only config-source gaps.
  5. The version cluster, as a follow-up.

Each should carry the matching test from the TS side where one exists, per the parity-testing rule in pnpm/AGENTS.md.


Written by an agent (Claude Code, claude-opus-5).

Activity

  1. added
    rust
    on Jul 31, 2026
  2. github-actions commented on Jul 31, 2026

    @github-actions

    Oz triage is running now and will classify this issue into one of: Ready to implement, Ready to spec, Needs info, or Wait to implement, and apply the corresponding pnpm state: label.

    Follow along in Oz: https://app.warp.dev/conversation/ccd51108-b099-498f-88b0-99e09255d858

  3. github-actions commented on Jul 31, 2026

    @github-actions

    Triage result

    • Issue: #13542 pacquet: publish auth settings are CLI-flag-only where the TypeScript CLI resolves them from config
    • State: Ready to spec
    • Applied label: state: needs design
    • Product / parity: Rust pacquet (pnpm/) only. The TypeScript CLI already resolves every listed setting correctly, so this is not a cross-stack parity gap to close in both stacks — it's a one-sided fix bringing pacquet in line with the existing, verified TS behavior.
    • Rationale: I verified the core claims against the current checkout (pnpm/crates/cli/src/cli_args/publish.rs, pnpm/crates/publish/src/otp_env.rs, pnpm/crates/publish/src/publish_options.rs) — access, tag, provenance, and publish-branch are indeed flag-only, and otp is env-only with no config-file source, matching the issue's line references. The write-up is unusually thorough (exact precedence traps, an existing precedent in fix(pacquet/login): honor the scope setting pnpm#13255 for the analogous scope fix, and a proposed sweep test), but it bundles at least 8 independent sub-fixes across two commands (publish's access/tag/provenance/publish-branch/otp plus feature gaps for skip-manifest-obfuscation/embed-readme/npm-path, and a version cluster called out as a follow-up) plus new test infrastructure. That breadth makes a single implementation pass risky even though no product decision is actually in question — the issue's own "Suggested order" effectively proposes splitting this into several scoped changes. state: needs design reflects that recommended breakdown step rather than any ambiguity in the desired behavior.
    • Next step: Split into per-option (or per-phase, following the issue's own suggested order) sub-tasks/PRs — starting with the rcOptionsTypes() sweep test, then the access/tag/provenance/publish-branch config-source wiring — each scoped tightly enough to implement and test in one pass.
  4. added theissue type on Jul 31, 2026
  5. self-assigned this
    on Jul 31, 2026
  6. transferred this issue frompnpm/pnpmon Sep 26, 2026
  7. zkochan commented on Nov 8, 2026

    @zkochan
    Member

    Status check against main (2026-11-08).

    publish-branch (pnpm/pnpm#17399) and provenance (pnpm/pnpm#16723) are now read from config, and embed-readme exists.

    Left: access and tag are still flag-only (publish/options.rs), otp is still env-only, and there is no rcOptions sweep test.

    Written by an agent (Claude Code, claude-opus-5-5).

  8. added a commit that references this issue on Nov 20, 2026
    a07908a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: 2ruststate: needs design

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions