{"record":{"id":"3cedf78e354ff2df","repo":"nexu-io/open-design","slug":"competitors-competitors-list-is-empty-n","errorCode":null,"errorMessage":"[Competitors] --competitors-list is empty.\\n","messagePattern":"\\[Competitors\\] --competitors-list is empty\\.\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"design-templates/last30days/scripts/last30days.py","lineNumber":433,"sourceCode":"def resolve_competitors_args(args: argparse.Namespace) -> tuple[bool, int, list[str]]:\n    \"\"\"Normalize --competitors / --competitors-list into (enabled, count, explicit_list).\n\n    - (False, 0, []) when neither flag is set.\n    - An explicit list always wins; count is derived from list length.\n    - A numeric count outside [1, 6] is clamped with a stderr warning.\n    - count <= 0 (explicit) raises SystemExit(2).\n    \"\"\"\n    explicit_list: list[str] = []\n    list_flag_provided = args.competitors_list is not None\n    if list_flag_provided:\n        explicit_list = [\n            entity.strip()\n            for entity in args.competitors_list.split(\",\")\n            if entity.strip()\n        ]\n        if not explicit_list:\n            sys.stderr.write(\"[Competitors] --competitors-list is empty.\\n\")\n            raise SystemExit(2)\n\n    competitors_flag = args.competitors\n    list_present = bool(explicit_list)\n    flag_present = competitors_flag is not None\n\n    if not list_present and not flag_present:\n        return False, 0, []\n\n    if list_present:\n        count = len(explicit_list)\n        if flag_present and competitors_flag != count:\n            sys.stderr.write(\n                f\"[Competitors] --competitors={competitors_flag} ignored; using \"\n                f\"{count} entries from --competitors-list.\\n\"\n            )\n        if count > COMPETITORS_MAX:\n            sys.stderr.write(\n                f\"[Competitors] --competitors-list has {count} entries, clamping to {COMPETITORS_MAX}.\\n\"","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/design-templates/last30days/scripts/last30days.py#L415-L451","documentation":"In resolve_competitors() (around line 433), when `--competitors-list` is provided (not None) the code splits on comma, strips, and discards empty entries. If the resulting explicit_list is empty, it writes `[Competitors] --competitors-list is empty.` to stderr and raises SystemExit(2). This catches `--competitors-list ''`, `--competitors-list ',,'`, etc. before any count logic runs.","triggerScenarios":"`--competitors-list \"\"`, `--competitors-list \",\"`, or `--competitors-list \" , \"` — flag present but every token empty after strip.","commonSituations":"Empty env var expanded into the flag; a templated command where the list variable was unset; user misunderstanding the flag as boolean.","solutions":["Provide at least one entity name: `--competitors-list acme,beta`.","Drop the flag entirely if you want auto-discovery via `--competitors N`.","Guard the shell variable: `--competitors-list \"${LIST:-acme}\"`."],"exampleFix":"# before\npython3.12 last30days.py --topic x --competitors-list \"$CLIST\"   # CLIST empty\n# after\npython3.12 last30days.py --topic x --competitors-list \"${CLIST:-acme,beta}\"","handlingStrategy":"validation","validationCode":"explicit = [e.strip() for e in (args.competitors_list or '').split(',') if e.strip()]\nif args.competitors_list is not None and not explicit:\n    raise ValueError('--competitors-list must contain at least one non-empty entity')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default empty shell vars: `${LIST:-acme}`.","Omit the flag when no list is needed."],"tags":["cli","argument-validation","python","competitors"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}