Skip to content

fix(cli): do not treat empty flag value without "=" as positional arg - #7399

Open
RealAdii wants to merge 1 commit into
denoland:mainfrom
RealAdii:fix/cli-parse-args-empty-string
Open

RealAdii wants to merge 1 commit into
denoland:mainfrom
RealAdii:fix/cli-parse-args-empty-string

Conversation

@RealAdii

Copy link
Copy Markdown

Closes #7351.

When an empty string was passed as the value of a flag as a separate argument (e.g., --foo "" or -f ""), parseArgs() checked if (next) and if (nextArg) using a truthiness check. Because "" is falsy in JavaScript, the argument was not consumed and i was not incremented, causing the empty string to be visited on the next iteration and pushed into argv._ as a positional argument.

This replaces the truthiness checks with if (next != null) and if (nextArg != null), allowing empty string values to be consumed as flag values rather than leaking into argv._.

@CLAassistant

CLAassistant commented Nov 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the cli label Nov 28, 2026
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (f834d02) to head (6398eac).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7399      +/-   ##
==========================================
- Coverage   95.04%   95.03%   -0.02%     
==========================================
  Files         619      618       -1     
  Lines       52012    51757     -255     
  Branches     9450     9403      -47     
==========================================
- Hits        49434    49185     -249     
+ Misses       2031     2022       -9     
- Partials      547      550       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: parseArgs() treats an empty flag value passed without "=" as a positional argument

2 participants