Skip to content

fix(cli): validate URL schemes and non-empty tokens in config set - #18604

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
lakshayjitsingh:fix/cli-config-set-url-validation
Sep 24, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
lakshayjitsingh:fix/cli-config-set-url-validation

Conversation

@lakshayjitsingh

@lakshayjitsingh lakshayjitsingh commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

Validates URL schemes for api_base and local_api_url and ensures non-empty values for local_token in omi config set.

Problem & Root Cause

In sdks/python-cli/omi_cli/commands/config.py, set_value() accepted arbitrary strings for profile configuration keys without validation:

  1. Setting api_base or local_api_url to invalid schemes (e.g. ftp://...), missing hosts (http://), or non-URL strings wrote corrupt values into ~/.omi/config.toml, causing subsequent CLI commands to fail with unhandled httpx.InvalidURL or connection errors.
  2. Setting local_token to an empty string or whitespace was silently saved.
  3. When setting a URL with a trailing slash (e.g. https://api.omi.me/), profile.api_base was saved with rstrip("/") but the success message and --json response emitted the unstripped input string.

Fix

  • Added urlsplit validation for api_base and local_api_url, rejecting schemes other than http or https and URLs without a host with a descriptive UsageError.
  • Enforced non-empty, non-whitespace checks for local_token.
  • Aligned display_value and JSON output to report the exact normalized stored value.
  • Expanded tests/test_config.py with 18 parameterized test cases verifying invalid URL rejection, valid URL normalization, and whitespace token rejection.

Verification

  • pytest tests/test_config.py: 69 passed, 2 skipped
  • Full test suite pytest: 528 passed, 2 skipped
  • black --check and isort --check: clean

Proposed Bounty

  • $25 (Python CLI bug fix & input hardening with hermetic unit tests)
  • PayPal: [email protected]

Review in cubic

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bug fix: omi config set accepted invalid URL schemes/empty tokens, corrupting config.toml. Root cause stated, scoped diff, thorough regression tests, confirmed not fixed on main. 5/5.

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.

2 participants