{"record":{"id":"ccc9b1234377dd11","repo":"nexu-io/open-design","slug":"unknown-config-key-args-key","errorCode":null,"errorMessage":"Unknown config key: {args.key}","messagePattern":"Unknown config key: (.+?)","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"design-templates/last30days/scripts/watchlist.py","lineNumber":252,"sourceCode":"    except json.JSONDecodeError as exc:\n        duration = time.time() - start_time\n        store.update_run(\n            run_id,\n            status=\"failed\",\n            error_message=f\"Invalid JSON output: {exc}\",\n            duration_seconds=duration,\n        )\n        return {\"topic\": topic[\"name\"], \"status\": \"failed\", \"error\": f\"parse error: {exc}\"}\ndef cmd_config(args):\n    if args.key == \"budget\":\n        store.set_setting(\"daily_budget\", str(args.value))\n        print(json.dumps({\"action\": \"config\", \"key\": \"daily_budget\", \"value\": str(args.value)}))\n        return\n    if args.key == \"delivery\":\n        store.set_setting(\"delivery_channel\", str(args.value))\n        print(json.dumps({\"action\": \"config\", \"key\": \"delivery_channel\", \"value\": str(args.value)}))\n        return\n    raise SystemExit(f\"Unknown config key: {args.key}\")\n\n\ndef build_parser() -> argparse.ArgumentParser:\n    parser = argparse.ArgumentParser(description=\"Manage the last30days watchlist\")\n    sub = parser.add_subparsers(dest=\"command\")\n\n    add = sub.add_parser(\"add\")\n    add.add_argument(\"topic\")\n    add.add_argument(\"--schedule\")\n    add.add_argument(\"--weekly\", action=\"store_true\")\n    add.add_argument(\"--queries\")\n    add.set_defaults(func=cmd_add)\n\n    remove = sub.add_parser(\"remove\")\n    remove.add_argument(\"topic\")\n    remove.set_defaults(func=cmd_remove)\n\n    list_parser = sub.add_parser(\"list\")","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/design-templates/last30days/scripts/watchlist.py#L234-L270","documentation":"Raised by cmd_config in watchlist.py via `raise SystemExit(...)` when the positional `key` argument is not one of the recognized config keys. The dispatcher only knows `budget` (writes daily_budget) and `delivery` (writes delivery_channel); anything else aborts the process with a non-zero exit. SystemExit (not ValueError) means argparse/CLI semantics: the error message is printed and the process exits.","triggerScenarios":"Invoking `watchlist config <unknown> <value>` with a key other than 'budget' or 'delivery' — e.g. `watchlist config interval 60`, `watchlist config source hn`, typos like `watchlist config delivry slack`, or guessing a key name from a different tool version.","commonSituations":"User assumes config keys mirror CLI flags or environment variables; outdated documentation/blog lists a key that was renamed or removed; tab-completion or shell history replay with a stale key; script wrapper passing user input straight through without validation.","solutions":["Use a supported key: `watchlist config budget <number>` or `watchlist config delivery <channel>`.","Run `watchlist config --help` (or read cmd_config in watchlist.py:240) to see the accepted keys for your installed version.","If you need a setting that is not budget/delivery, check store.set_setting's known keys and environment variables (OD_*) instead of guessing a config subcommand.","If wrapping this CLI from another script, validate the key against {'budget','delivery'} before invoking to produce a cleaner error."],"exampleFix":"// before\npython3 watchlist.py config interval 60\n# -> SystemExit: Unknown config key: interval\n\n// after\npython3 watchlist.py config delivery slack\n# or for budget\npython3 watchlist.py config budget 30","handlingStrategy":"validation","validationCode":"SUPPORTED_CONFIG_KEYS = {\"budget\", \"delivery\"}\n\nif args.key not in SUPPORTED_CONFIG_KEYS:\n    raise SystemExit(\n        f\"Unknown config key: {args.key}. \"\n        f\"Supported: {', '.join(sorted(SUPPORTED_CONFIG_KEYS))}\"\n    )\n# then dispatch","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When wrapping watchlist from a script, validate the key against the known set before invoking.","Expose supported keys via `watchlist config --help` or `--list-keys`.","Treat SystemExit from this CLI as a user-input error and surface the message to the end user.","Keep a single source of truth for supported keys (a module constant) and derive both dispatch and help from it."],"tags":["cli","argparse","config","validation","last30days"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}