Skip to content

fix(cli): allow empty strings and falsy values in config set#4301

Closed
dsr-restyn wants to merge 1 commit into
NousResearch:mainfrom
dsr-restyn:fix/config-set-blank-value
Closed

fix(cli): allow empty strings and falsy values in config set#4301
dsr-restyn wants to merge 1 commit into
NousResearch:mainfrom
dsr-restyn:fix/config-set-blank-value

Conversation

@dsr-restyn

Copy link
Copy Markdown
Contributor

Summary

hermes config set KEY "" prints usage and exits instead of setting the value. The guard at hermes_cli/config.py:2043 uses not value, which is truthy for "", "0", and False. Users cannot blank stale config values via the CLI — they have to manually edit config.yaml.

Reported by a user who needed to clear OPENROUTER_API_KEY after migrating to a local Ollama endpoint.

Closes #4277

Changes

  • hermes_cli/config.py: Changed not valuevalue is None in the config_command set guard. Argparse gives None when the positional is omitted (nargs="?"), so this correctly rejects missing arguments while accepting empty strings and zero
  • tests/hermes_cli/test_set_config_value.py: 5 new regression tests — empty string to .env, empty string to config.yaml, zero to config.yaml, missing value rejection, and config_command entry point acceptance

Testing

  • 31/31 tests pass in test_set_config_value.py (26 existing + 5 new)
  • Manually verified: config set model "" writes model: '', config set OPENROUTER_API_KEY "" writes OPENROUTER_API_KEY=, config set verbose 0 writes verbose: 0, and omitting the value arg still prints usage and exits
  • Tested on Linux (Arch, Python 3.11)

`hermes config set KEY ""` and `hermes config set KEY 0` were rejected
because the guard used `not value` which is truthy for empty strings,
zero, and False. Changed to `value is None` so only truly missing
arguments are rejected.

Closes NousResearch#4277

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #4310. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks @dsr-restyn!

@teknium1 teknium1 closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] hermes config set cannot blank a value — rejects empty strings and falsy values

2 participants