Repository navigation
fix(cli): reject malformed URLs in config set - #19689
undivisible merged 1 commit into
Conversation
`omi config set` currently leaks a raw ValueError for `http://[` (instead of a clean UsageError), accepts lazily-validated ports such as `http://example.test:abc` and `https://example.test:65536`, and saves an authority without a hostname like `http://:47778`. Force url split validation (`.port` / `.hostname` access) so all three classes fail with the existing UsageError, and add regression tests plus an IPv6 positive case. Addresses BasedHardware#18904
|
Thanks for the clean follow-up to #18604 — verified the three gaps and the fix on this head:
One note: the Python CLI CI jobs are skipped on this PR path, so the reported local Nice, narrow fix addressing #18904. Leaving for routine maintainer review. This review was posted by an AI reviewer operating as a maintainer assistant on David's behalf. AI-generated feedback — human maintainer judgment applies. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Verified this follow-up hardening of
Minor note, non-blocking: for a URL like CI checks are path-skipped for this fork PR as expected; your local run (81 passed / 2 skipped) matches what the diff suggests. Leaving merge sign-off to a maintainer — this looks ready. This review was generated by AI on behalf of the Omi maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
a5eda9b8d294 — sdks/python-cli/omi_cli/commands/config.py set_value still lets urlsplit raise ValueError on http://[ before UsageError. This head catches that and rejects an empty hostname. Tests pin http://[, :abc, and port 65536. 12 checks passed, none failing.
|
Hi @aryanorastar, just checking if there's anything else needed for this PR to be merged? Thanks! |
|
Hi @kodjima33 — friendly follow-up on this one: it has been APPROVED by @aryanorastar, CI is green, and mergeable state is clean. It only needs a merge when convenient. Thanks! |
|
Hi @kodjima33 — gentle nudge: CI is green and this merges cleanly. Would be great to get it merged when you have a moment. Thanks! |
|
Hi! This PR has been approved and all CI checks pass. Could you merge it when you have time? Thanks! |
1 similar comment
|
Hi! This PR has been approved and all CI checks pass. Could you merge it when you have time? Thanks! |
|
Hey @1132dadf 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
|
Verified the root-cause analysis and the fix independently (reproduced
One non-blocking nit for a future pass: AI-generated maintainer feedback on behalf of the Omi maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Hi maintainer! This PR has already been approved and open for 12 days, all checks pass, could you please merge it so I can receive the $10 bounty payout? Thank you! |
|
Hi @aryanorastar! This PR has been approved and all checks pass, could you please merge it now so I can receive the $10 bounty payout as soon as possible? Thank you so much! |
`omi config set api_base` checks URLs since BasedHardware#19689, but the value a command actually uses can also come from --api-base, $OMI_API_BASE, or a config saved before that check, and none of those are checked. httpx raises UnsupportedProtocol for `localhost:8000` or `ftp://...`, which the client treats as a transport failure: reads retry for several seconds and end in "Connection failed" (exit 3), and writes report "POST outcome unknown: the server may have applied this write", though nothing left the machine. The config set check is now a shared helper, and make_client runs it on the resolved API base, so every source fails fast with the same "Invalid URL for 'api_base'" usage error.
`omi config set api_base` checks URLs since #19689, but the value a command actually uses can also come from --api-base, $OMI_API_BASE, or a config saved before that check, and none of those are checked. httpx raises UnsupportedProtocol for `localhost:8000` or `ftp://...`, which the client treats as a transport failure: reads retry for several seconds and end in "Connection failed" (exit 3), and writes report "POST outcome unknown: the server may have applied this write", though nothing left the machine. The config set check is now a shared helper, and make_client runs it on the resolved API base, so every source fails fast with the same "Invalid URL for 'api_base'" usage error.
|
Hi |
Summary
Follow-up hardening of
omi config setURL validation (on top of #18604): three malformed URL classes still crash with a raw traceback or slip through validation and get persisted. Addresses #18904.Problem & Root Cause
In
sdks/python-cli/omi_cli/commands/config.py(set_value()), theurlsplit(...)+ scheme/netloc check misses three cases:http://[—urlsplitraisesValueError: Invalid IPv6 URLat the validation point; nothing catches it, so the CLI exits with an unhandled traceback instead of a cleanUsageError.http://example.test:abc/https://example.test:65536— port parsing inurlsplitis lazy; only accessing.portraises. The check never touches.port, so both are accepted, saved, and later blow up when an HTTP client parses the configured base URL.http://:47778— the netloc is non-empty (:47778), so the netloc check passes, but there is no hostname; the value is accepted and saved.Fix
urlsplitplus eager.port/.hostnameaccess in atry/except ValueErrorand re-raise as the existingUsageError(Invalid URL for '<key>'+ the same detail message as the other rejection paths).parsed.hostnamein the accept condition so an authority without a hostname is rejected.Verification
pytest tests/test_config.py— 81 passed, 2 skipped.test_config_set_rejects_malformed_urls: 8 cases ({"http://[", "http://example.test:abc", "https://example.test:65536", "http://:47778"}×{api_base, local_api_url}) assert non-zero exit, theInvalid URLmessage, and an unchanged config file.http://[::1]:8000accepted (new case in the existing accept/normalize test); trailing-slash normalization unchanged.black --checkandisort --check-onlyclean on both changed files.Tests
test_config_set_rejects_malformed_urls(new) — one case for each of the three defect classes.test_config_set_accepts_valid_urls_and_normalizes_trailing_slash— extended with the IPv6 positive case.Failure class
Failure-Class: none