Skip to content

Malformed or empty config.toml panics before argument parsing (even zoo --help is unavailable) #1753

Description

@sneg55

Malformed or empty config.toml panics before argument parsing, so even zoo --help and zoo version are unavailable

Context: API Makeathon participant. Found while reviewing CLI startup.

The CLI unwraps configuration loading before it parses arguments: parse_default_config() is unwrapped at src/main.rs:187, and a prompt lookup is unwrapped at src/context.rs:243. Argument parsing only begins afterward (src/main.rs:191-193). A malformed TOML file, or a valid but empty config.toml that lacks an expected key, is an ordinary recoverable configuration error, not an invariant, but the unwrap turns it into a Rust panic.

Concrete failure

With a malformed or empty config.toml, every invocation panics, including recovery commands: zoo --help and zoo version cannot run, so a user cannot even discover how to point at a different config.

Verify

Point ZOO_CONFIG_DIR at a directory with a malformed TOML config, then at one with an empty TOML config. Both paths panic instead of returning a configuration diagnostic.

Suggested fix

Return a configuration error (with the file path and parse message) instead of unwrapping, and let argument parsing run first so --help and version remain usable when the config is broken.

Environment

Zoo CLI v0.2.184 (33534cd). Reviewed against the current main of KittyCAD/cli.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions