Register alternate flags used by Param.orElse - #6952
Conversation
🦋 Changeset detectedLatest commit: 8a4c9f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR title and commit message say alternate flags are now registered, but the diff only adds the failing reproduction test. The actual implementation fix is missing from packages/effect/src/unstable/cli/Param.ts, so CI will stay red. Push the fix to this branch before merging, or convert the PR to draft and adjust the title.
Reviewed changes
- Added a focused reproduction test in
packages/effect/test/unstable/cli/Param.test.tsthat demonstratesFlag.orElse(...Flag.string("config-url"))is rejected as an unrecognized option.
⚠️ Implementation fix is missing
The reproduction test is accurate and currently fails with UnrecognizedOption: --config-url. The PR does not yet contain the registration change promised by the title.
Technical details
# Missing alternate flag registration
## Affected sites
- `packages/effect/src/unstable/cli/Param.ts:1861` — `orElse` wraps the fallback param in a parse-time closure inside a `Transform` node.
- `packages/effect/src/unstable/cli/Param.ts:1907` — same pattern in `orElseResult`.
- `packages/effect/src/unstable/cli/Param.ts:2149` — `extractSingleParams` for `Transform` only recurses into `mapped.param`, so the alternate name is never surfaced.
- `packages/effect/src/unstable/cli/internal/parser.ts:59` — command-level flag registry is built from `extractSingleParams`.
## Required outcome
- `orElse`/`orElseResult` register all potential fallback `Single` params for lexer/parser validation.
- The existing reproduction assertions remain unchanged and should pass once the fix is added.
## Suggested approach
- Extend the `Transform` representation to retain the fallback constructor, or otherwise make fallback singles discoverable by `extractSingleParams`.
- Apply the same treatment to `orElseResult`.
- Consider adding a `Command.run` test to verify the alternate flag value flows to the original field.@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
Run failed. View the logs →
|
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
A valid alternate flag supplied through Param.orElse is rejected as unrecognized before fallback parsing can run.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Param.orElse alternate flags are not registered
Module:
cli/ParamAudit ID:
unstable-ai-cli-param-orelse-flag-registrationSeverity / confidence: high / high
What happens
A valid alternate flag supplied through Param.orElse is rejected as unrecognized before fallback parsing can run.
Why it happens
The fallback is retained only in a transform closure, while parameter extraction traverses only the primary parameter and omits the alternate name from the command registry.
Expected behavior
Param.orElse accepts a fallback parameter, including one with a different flag name.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/cli/Param.ts:1847-1862packages/effect/src/unstable/cli/Param.ts:2143-2152packages/effect/src/unstable/cli/internal/parser.ts:59-61View problematic code at
packages/effect/src/unstable/cli/Param.ts:1847-1862View exact lines on GitHub
View problematic code at
packages/effect/src/unstable/cli/Param.ts:2143-2152View exact lines on GitHub
View problematic code at
packages/effect/src/unstable/cli/internal/parser.ts:59-61View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/cli/ParamOrElseFlag.audit.test.tsObserved failure: FAIL: --config-url produced UnrecognizedOption.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/effect/test/unstable/cli/ParamOrElseFlag.audit.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-ai-cli-param-orelse-flag-registrationCloses EFF-398