CLI errors

Common error signatures

Errors in the CLI fall into two categories: argument parsing failures raised before any retrieval logic runs, and runtime failures returned as non-zero exit codes from main().

Where errors originate

Both functions in src/attune_rag/cli.py are potential failure sites:

How to diagnose

  1. Check the exit code. A code of 2 points to an argument parsing error in build_parser(). Any other non-zero code points to a failure inside main().

  2. Read the argparse error message. When argument parsing fails, argparse prints the specific problem — missing argument, unrecognized flag, or invalid value — directly to stderr before exiting.

  3. Pass argv explicitly during debugging. Because main() accepts an optional argv: list[str] parameter, you can call it directly in a Python session with a known-good argument list to isolate whether the failure is in argument parsing or in retrieval logic.

  4. Capture the full traceback for unexpected exceptions. If main() raises rather than returning a non-zero integer, the traceback will name the exact file and line. Errors originating outside cli.py itself indicate the CLI is propagating a failure from the retrieval layer.

Source files

Tags: cli, query, corpus-info