Skip to content

fix(cli): report an invalid config.toml as one readable error instead of a traceback - #2002

Open
pcbeingused333 wants to merge 1 commit into
TokenRhythm:mainfrom
pcbeingused333:fix/cli-config-validation-errors
Open

pcbeingused333 wants to merge 1 commit into
TokenRhythm:mainfrom
pcbeingused333:fix/cli-config-validation-errors

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Scope

A semantically invalid value in config.toml (for example a Slack socket channel without app_token) made channels list|enable|remove, agents list, skills list and gateway status print a 47–64 line pydantic traceback, while doctor and onboard status already reported the same problem as one line plus a recovery command.

The one-line error already existed in onboard_cmd.py. This moves its formatter and exit helper to cli/config_errors.py (same message, exit code 2) and uses it where the traceback came out: the channels commands, agents, skills offline loading, the config read behind the Gateway URL (which is what skills list crashed in), and the ValidationError branch of gateway status that re-raised everything but the port error.

Scope boundary: CLI error output for the sites reproduced in #1988. Behavior and messages of onboard are unchanged.

Non-goals: converting ValidationError into a domain error inside the config loaders, the consistency test that counts unguarded load sites, and the other unguarded sites that were not reproduced.

Branch

Base branch: main
Target exception: N/A

Issue

Linked issue: Fixes #1988

Release Note

Release note: An invalid value in config.toml is now reported as one readable error with a recovery command, instead of a Python traceback, by channels, agents, skills list and gateway status.

Tests

Ruff: ruff check passes on src/opensquilla/cli and the new test.
Pytest: tests/test_cli/test_config_load_errors.py: 9 passed; tests/test_cli: 1037 passed, 2 failed in test_diagnostics_smoke.py because tiktoken was not installed in the test environment.
Build: not run. No frontend changes.
Regression tests: added
Notes:

  • The new test runs each affected command against the Slack-socket-without-app_token config from the issue and asserts exit code 2, the readable message and the onboarding hint, and no traceback. All 7 fail on main and pass with the change.
  • test_invalid_implicit_config_is_reported_once covers a broken config found without --config or an environment variable (skills list, gateway status) and asserts the error block is printed exactly once: default_gateway_target swallows load failures on the implicit path and falls back to the default URL, so the exit has to happen only where the user named the config path, or skills list would print the block twice.
  • Not run on Windows or macOS, or in a real terminal.

Maintainer Live Check

Maintainer live check: no
Surface: N/A

Safety

No secrets, local-only artifacts, private prompts or transcripts, channel identifiers or non-public fixtures are committed; the test fixture is the config from the issue with a placeholder token.

Third-Party Origin

Third-party origin: none

Documentation Changes

  • Links point to existing repository files or stable external pages.
  • Code fences and Markdown tables render correctly on GitHub.
  • Examples avoid real secrets, local private paths, and private transcripts.

This change was prepared with Claude Code (AI-assisted); the tests above were run.

🤖 Generated with Claude Code

… of a traceback

Fixes TokenRhythm#1988

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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]: config.toml 少写一个必填字段,channels list 就吐 47 行 Python 堆栈;同一份配置 doctor 给的是 1 行诊断 + 恢复命令

1 participant