{"record":{"id":"72d5d517eeef9b52","repo":"affaan-m/ECC","slug":"unknown-flag-arg","errorCode":null,"errorMessage":"Unknown flag: {arg}","messagePattern":"Unknown flag: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/videodb/scripts/ws_listener.py","lineNumber":87,"sourceCode":"    \"\"\"Create the listener state directory with private permissions.\"\"\"\n    path.mkdir(parents=True, exist_ok=True, mode=0o700)\n    try:\n        path.chmod(0o700)\n    except OSError:\n        pass\n    return path\n\n\ndef parse_args() -> tuple[bool, Path]:\n    clear = False\n    output_dir: str | None = None\n    \n    args = sys.argv[1:]\n    for arg in args:\n        if arg == \"--clear\":\n            clear = True\n        elif arg.startswith(\"-\"):\n            raise SystemExit(f\"Unknown flag: {arg}\")\n        elif not arg.startswith(\"-\"):\n            output_dir = arg\n    \n    if output_dir is None:\n        events_dir = os.environ.get(\"VIDEODB_EVENTS_DIR\")\n        if events_dir:\n            return clear, ensure_private_dir(Path(events_dir))\n        return clear, ensure_private_dir(default_output_dir())\n\n    return clear, ensure_private_dir(Path(output_dir))\n\nCLEAR_EVENTS, OUTPUT_DIR = parse_args()\nEVENTS_FILE = OUTPUT_DIR / \"videodb_events.jsonl\"\nWS_ID_FILE = OUTPUT_DIR / \"videodb_ws_id\"\nPID_FILE = OUTPUT_DIR / \"videodb_ws_pid\"\n\n# Track if this is the first connection (for clearing events)\n_first_connection = True","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/videodb/scripts/ws_listener.py#L69-L105","documentation":"Argument guard in parse_args: a command-line argument starting with '-' was encountered that is not the recognized --clear flag. The ws_listener accepts only --clear and an optional positional output directory; anything else dashed aborts startup.","triggerScenarios":"Running python ws_listener.py --dir ./out or --help or any unsupported flag like -v.","commonSituations":"Users assuming a full argparse-style interface; copy-pasting flags from other tools; expecting --help to work.","solutions":["Use only '--clear' or a bare positional output directory: python ws_listener.py /path/to/out","Set VIDEODB_EVENTS_DIR env var instead of passing a directory flag","Check the script's usage — there are no other flags supported"],"exampleFix":"// before\npython ws_listener.py --dir ./events\n// after\npython ws_listener.py ./events","handlingStrategy":"validation","validationCode":"allowed = {'--clear'}\nbad = [a for a in sys.argv[1:] if a.startswith('-') and a not in allowed]\nif bad:\n    sys.exit(f'Unknown flag(s): {bad}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the script header for supported flags before running","Use only '--clear' and a positional directory","Prefer setting VIDEODB_EVENTS_DIR over CLI flags for paths","Wrap the script in argparse if a richer CLI is needed"],"tags":["cli","argument-error","systemexit"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}