Skip to content

Fix:(issue_2293) --flag="" no longer rejected as missing argument - #2297

Merged
dearchap merged 1 commit into
urfave:mainfrom
idelchi:issue_2293
Mar 25, 2026
Merged

dearchap merged 1 commit into
urfave:mainfrom
idelchi:issue_2293

Conversation

@idelchi

@idelchi idelchi commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • bug

What this PR does / why we need it:

--flag= (explicit empty value via =) is rejected with "flag needs an argument" instead of setting the flag to an empty string. This is a side effect of #2223 where the valFromEqual guard was made slightly too broad.

Tightened the condition to flagVal == "" && !valFromEqual so the "fetch next arg" block is skipped entirely when = was used. The #2223 fix is preserved — no arg consumption happens.

Which issue(s) this PR fixes:

Fixes #2293

Testing

Added TestFlagEqualsEmptyValue with two subtests (sets empty string, does not consume next positional arg). Updated two existing TestFlagAction expectations that encoded the broken behavior.

go test -run=TestFlagEqualsEmptyValue
go test -run=TestFlagAction/flag_string_error

Release Notes

`--flag=` now sets the flag to an empty string instead of erroring.
@idelchi
idelchi requested a review from a team as a code owner March 25, 2026 07:35
Comment thread command_test.go Outdated
@dearchap
dearchap merged commit 41c4f5f into urfave:main Mar 25, 2026
9 checks passed
Maks1mS pushed a commit to stplr-dev/stplr that referenced this pull request Mar 28, 2026
This PR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [github.com/urfave/cli/v3](https://github.com/urfave/cli) | require | minor | `v3.7.0` → `v3.8.0` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/urfave/cli/badge)](https://securityscorecards.dev/viewer/?uri=github.com/urfave/cli) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/23) for more information.

---

### Release Notes

<details>
<summary>urfave/cli (github.com/urfave/cli/v3)</summary>

### [`v3.8.0`](https://github.com/urfave/cli/releases/tag/v3.8.0)

[Compare Source](urfave/cli@v3.7.0...v3.8.0)

#### What's Changed

- chore(deps): bump mkdocs-material from 9.7.1 to 9.7.2 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2267](urfave/cli#2267)
- chore(deps): bump mkdocs-material from 9.7.2 to 9.7.3 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2272](urfave/cli#2272)
- chore(deps): bump mkdocs-material from 9.7.3 to 9.7.4 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2276](urfave/cli#2276)
- Fix: check MutuallyExclusiveFlags across parent command chain by [@&#8203;siutsin](https://github.com/siutsin) in [#&#8203;2274](urfave/cli#2274)
- Modernize source code by [@&#8203;kolyshkin](https://github.com/kolyshkin) in [#&#8203;2289](urfave/cli#2289)
- flag: replace regexp use by [@&#8203;kolyshkin](https://github.com/kolyshkin) in [#&#8203;2288](urfave/cli#2288)
- chore(deps): bump mkdocs-material from 9.7.4 to 9.7.5 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2284](urfave/cli#2284)
- Fix:(issue\_2281) Remove incorrect check for local flag for set by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2290](urfave/cli#2290)
- Fix:(issue\_2275) Make flag action execution consistent by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2295](urfave/cli#2295)
- Fix:(issue\_2293) --flag="" no longer rejected as missing argument by [@&#8203;idelchi](https://github.com/idelchi) in [#&#8203;2297](urfave/cli#2297)
- Fix:(issue\_2292) Empty positional args no longer break parse loop by [@&#8203;idelchi](https://github.com/idelchi) in [#&#8203;2296](urfave/cli#2296)

#### New Contributors

- [@&#8203;idelchi](https://github.com/idelchi) made their first contribution in [#&#8203;2297](urfave/cli#2297)

**Full Changelog**: <urfave/cli@v3.7.0...v3.8.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday ( * 0-4,22-23 * * 1-5 ), Only on Sunday and Saturday ( * * * * 0,6 ) (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44Ni4xIiwidXBkYXRlZEluVmVyIjoiNDMuODYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9EZXBlbmRlbmNpZXMiXX0=-->

Reviewed-on: https://altlinux.space/stapler/stplr/pulls/376
Co-authored-by: Renovate Bot <stapler-helper-bot@noreply.altlinux.space>
Co-committed-by: Renovate Bot <stapler-helper-bot@noreply.altlinux.space>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants