Repository navigation
fix(cli): reject non-ASCII characters in developer API keys - #20406
Conversation
validate_api_key_format now rejects keys containing non-ASCII characters with a clear UsageError before any network round-trip, matching the issue repro (key with a CJK character passes prefix+length checks today).
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Follows the non-ASCII rejection from 33f01d1: a key with an interior space or a control byte still slipped through isascii()+length checks and failed late at the HTTP verification round-trip. The backend pattern is omi_dev_ + 32 hex chars, so printable-ASCII-only is the correct client-side contract.
|
Hi @kodjima33 — could you take a look at this PR when you have a moment? It fixes #20401 (CLI currently rejects non-ASCII developer keys as invalid input). The change is scoped to Thanks! |
|
Thanks @1132dadf - nice, tight fix. Reviewed both changed files at the current head. sdks/python-cli/omi_cli/auth/api_key.py
sdks/python-cli/tests/test_auth_api_key.py
The implementation looks correct and well-tested. Since this touches an auth-adjacent input path, it needs maintainer sign-off before merge rather than automated approval. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Hi |
Summary
omi auth loginnow rejects developer API keys containing non-ASCII characters (e.g. a CJK character or emoji) with a clean usage error, instead of accepting the key and only failing later during the verification round-trip. Closes #20401.Root cause
validate_api_key_format()insdks/python-cli/omi_cli/auth/api_key.pyonly checks theomi_dev_prefix and a minimum length, so a key likeomi_dev_aaaaaaaaaaaaaaaaaaaa中passes client-side validation and proceeds to the HTTP verification call, producing a confusing late failure instead of an immediate input error. All login entry points (--api-key, piped stdin, interactive paste) funnel through this function, so a single check covers all of them.Test plan
UsageErrorfromvalidate_api_key_format().omi --json auth login --api-key "omi_dev_…中"exits with code 1 (usage error) and performs zero API round-trips.pytest tests/test_auth_api_key.pyon this host: all validation/login-rejection tests pass. The remaining tests in that file error only on this Windows host due to the pre-existing owner-only DACL read-back check added in 0c4d6e7 (_secure_file.py), unrelated to this change; the Linux CI job runs the full suite via the POSIX secure-file path.Failure class (fixes)
Failure-Class: none