Skip to content

fix(cli): prevent --log-level=value from swallowing next argument#6144

Merged
IMax153 merged 3 commits intoEffect-TS:mainfrom
LikiosSedo:fix/cli-log-level-equals-syntax
Mar 31, 2026
Merged

fix(cli): prevent --log-level=value from swallowing next argument#6144
IMax153 merged 3 commits intoEffect-TS:mainfrom
LikiosSedo:fix/cli-log-level-equals-syntax

Conversation

@LikiosSedo
Copy link
Copy Markdown
Contributor

Summary

When using --log-level=debug (equals syntax), the SetLogLevel handler incorrectly strips the next argument too.

Root Cause

The argument filter loop checks isLogLevelArg(args[i - 1]), which matches the combined form --log-level=debug. This causes the argument at i (the one after the log-level flag) to be skipped.

args: ["--log-level=debug", "--name=hello"]

i=0: "--log-level=debug" → isLogLevelArg matches → skip (correct)
i=1: "--name=hello" → isLogLevelArg(args[0]) matches "--log-level=debug" → skip (BUG)

Fix

Change the look-back check from isLogLevelArg(args[i - 1]) to args[i - 1] === "--log-level". This ensures only the space-separated value (e.g. debug after --log-level debug) is skipped, not the argument following a combined --log-level=value form.

Reproduction

// --log-level=debug --name=hello → name = None (bug)
// --log-level debug --name=hello → name = Some("hello") (works)

Fixes #6103

When using equals syntax (--log-level=debug), the argument filter
incorrectly skips the next argument because isLogLevelArg() matches
the combined form. Only skip the next arg when the previous arg is
exactly "--log-level" (space-separated syntax).

Fixes Effect-TS#6103
@LikiosSedo LikiosSedo requested a review from IMax153 as a code owner March 25, 2026 04:48
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Mar 25, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

🦋 Changeset detected

Latest commit: 0649275

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/cli Patch

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

Copy link
Copy Markdown
Member

@IMax153 IMax153 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LikiosSedo - we will need a few test cases added to the CLI test suite to prevent further regressions. Once added, I can trigger CI.

@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Mar 30, 2026
- Test that --log-level=value does not swallow the next argument
- Test that both log level and argument are correctly set together
@IMax153 IMax153 merged commit ec5c505 into Effect-TS:main Mar 31, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in PR Backlog Mar 31, 2026
This was referenced Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

From Discord: Bug in Effect CLI: --log-level=debug Argument Parsing Swallows Next Argument

2 participants