-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Bug Report: TypeError on CLI initialization - "Secondary flag is not valid for non-boolean flag"
Description
CAM fails to initialize with a TypeError when running any command, including cam --help. The error occurs during Typer/Click CLI initialization due to incorrect use of short flags on non-boolean options.
Error Message
TypeError: Secondary flag is not valid for non-boolean flag.
Root Cause
Throughout the codebase, non-boolean typer.Option() definitions incorrectly include short flags (e.g., -c, -s, -n, -o, -b, -f, -d, -a, -l, -m).
In Click/Typer, only boolean flags can have both a long form (--flag) and short form (-f). Non-boolean options (strings, paths, integers, etc.) can only use long-form flags.
Affected Files
The issue affects at least 12 files across the codebase:
cli/agents_commands.pycli/app.pycli/options.pycli/plugins/plugin_discovery_commands.pycli/plugins/plugin_install_commands.pycli/plugins/plugin_management_commands.pycli/plugins/plugin_marketplace_commands.pycli/prompts_commands.pycli/skills_commands.pymcp/cli.pymcp/install_commands.pymcp/server_commands.py
Example Problematic Code
# INCORRECT - non-boolean option with short flag
CONFIG_FILE_OPTION = typer.Option(None, "--config", "-c", help="Path to config file")
SCOPE_OPTION = typer.Option("user", "--scope", "-s", help="Configuration scope")
OWNER_OPTION = typer.Option(..., "--owner", "-o", help="Repository owner")
# CORRECT - only long flag for non-boolean options
CONFIG_FILE_OPTION = typer.Option(None, "--config", help="Path to config file")
SCOPE_OPTION = typer.Option("user", "--scope", help="Configuration scope")
OWNER_OPTION = typer.Option(..., "--owner", help="Repository owner")
# CORRECT - boolean options can have short flags
DEBUG_OPTION = typer.Option(False, "--debug", "-d", help="Enable debug logging")
FORCE_OPTION = typer.Option(False, "--force", "-f", help="Skip confirmation prompt")Additional Issue: Boolean Flag with Parameter Name Conflict
In cli/prompts_commands.py, there's also an issue where a boolean flag uses the Python parameter name in the CLI declaration:
# INCORRECT - parameter name included in param_decls
default: Optional[bool] = typer.Option(None, "--default/--no-default", help="...")
# This creates param_decls = ['default', '--default/--no-default']
# where 'default' is treated as a short flagSteps to Reproduce
- Install CAM from the repository (commit
0f79489a8abac6cd298442c7a7c3f67ce215bc6bor tag 1.3.0) - Run
cam --helpor any CAM command - Observe the TypeError
Environment
- CAM Version: 0.0.0 (tag 1.3.0, commit 0f79489)
- Python Version: 3.11
- Typer Version: 0.12.5
- Click Version: 8.3.1
- OS: macOS (Darwin 25.2.0)
Expected Behavior
CAM should initialize successfully and display help or execute commands.
Actual Behavior
CAM fails during initialization with a TypeError before any command can execute.
Suggested Fix
Remove all short flags from non-boolean typer.Option() definitions throughout the codebase. The pattern to fix is:
# Find and replace pattern:
typer.Option(value, "--long-flag", "-s", help=...)
# Replace with:
typer.Option(value, "--long-flag", help=...)Only boolean options (with True/False as the first argument or is_flag=True) should retain short flags.
Workaround
Users can manually patch the installed package by removing short flags from the affected files, but this requires post-installation modifications to the site-packages directory.
Impact
Critical - The tool is completely unusable without patching. No commands can execute, including --help.
Additional Notes
This appears to be a systemic issue suggesting the original development may have used an older version of Click/Typer with different flag behavior, or the flag definitions were never tested with the current versions of these dependencies.