Skip to content

fix(config): stop reporting broken configs and unknown profiles as "no API token" - #87

Merged
ernestoongaro merged 1 commit into
mainfrom
fix/config-resolve-errors
Aug 28, 2026
Merged

fix(config): stop reporting broken configs and unknown profiles as "no API token"#87
ernestoongaro merged 1 commit into
mainfrom
fix/config-resolve-errors

Conversation

@ernestoongaro

Copy link
Copy Markdown
Collaborator

config.Resolve did cfg, _ := Load(), so three unrelated failures all produced the same message — "no API token configured. Set OMNI_API_TOKEN, use --token, or run omni config init":

  • omni -p typo models list
  • a malformed / unreadable config.json
  • (and consequently any transient read failure)

Now:

$ omni -p nope models list
Error: profile "nope" not found in ~/.config/omni-cli/config.json (available: acme, prod, …)

$ omni models list   # with a truncated config.json
Error: loading config ~/.config/omni-cli/config.json: parsing config: unexpected end of JSON input

A missing config file is still silent (env/flags may carry everything), and a broken file is ignored when both --token and --base-url are supplied. Tests added for both paths.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ei8UYaG1bW5PJhk93EaqzA

…o API token"

Resolve() discarded Load()'s error, so a malformed or unreadable config.json,
and a -p naming a profile that doesn't exist, all surfaced as "no API token
configured. Set OMNI_API_TOKEN, use --token, or run `omni config init`" —
advice that sends the caller to re-authenticate when the real fix is a typo
or a corrupt file.

- An unknown -p (or an unknown defaultProfile) now errors immediately,
  naming the config path and listing the available profiles.
- A config file that exists but fails to load is reported as such whenever
  the config is actually needed; when --token and --base-url are both given
  the file is still ignored. A missing file remains the silent, normal case.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ei8UYaG1bW5PJhk93EaqzA
@ernestoongaro
ernestoongaro requested a review from dspangen August 28, 2026 13:03

@dspangen dspangen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice improvement

@ernestoongaro
ernestoongaro merged commit 19280dd into main Aug 28, 2026
2 checks passed
@ernestoongaro
ernestoongaro deleted the fix/config-resolve-errors branch August 28, 2026 14:08
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