{"record":{"id":"0626afbf92a33959","repo":"usestrix/strix","slug":"target-list-path-must-not-be-empty","errorCode":null,"errorMessage":"--target-list path must not be empty.","messagePattern":"--target-list path must not be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/utils.py","lineNumber":1212,"sourceCode":"\n    raise ValueError(\n        f\"Invalid target: {target}\\n\"\n        \"Target must be one of:\\n\"\n        \"- A valid URL (http:// or https://)\\n\"\n        \"- A Git repository URL (https://host/org/repo or git@host:org/repo.git)\\n\"\n        \"- A local directory path\\n\"\n        \"- An API spec file (OpenAPI/Swagger .json/.yaml or a Postman collection)\\n\"\n        \"- A Postman collection by id (postman://<collection-uid>[?env=<environment-uid>], \"\n        \"needs POSTMAN_API_KEY)\\n\"\n        \"- A domain name (e.g., example.com)\\n\"\n        \"- An IP address (e.g., 192.168.1.10)\"\n    )\n\n\ndef read_target_list_file(path_str: str) -> list[str]:\n    \"\"\"Read scan targets from a file, one target per non-empty, non-comment line.\"\"\"\n    if not path_str or not path_str.strip():\n        raise ValueError(\"--target-list path must not be empty.\")\n\n    path = Path(path_str).expanduser()\n    if not path.is_file():\n        raise ValueError(f\"Target list file '{path_str}' is not an existing file.\")\n\n    try:\n        targets = [\n            target\n            for line in path.read_text(encoding=\"utf-8\").splitlines()\n            if (target := line.strip()) and not target.startswith(\"#\")\n        ]\n    except UnicodeDecodeError as e:\n        raise ValueError(f\"Target list file '{path_str}' must be valid UTF-8 text: {e!s}\") from e\n    except OSError as e:\n        raise ValueError(f\"Failed to read target list file '{path_str}': {e!s}\") from e\n\n    targets = [target for target in targets if target]\n    if not targets:","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/utils.py#L1194-L1230","documentation":"read_target_list_file validates its input before touching the filesystem: an empty or whitespace-only path string for --target-list is rejected immediately. This distinguishes 'the flag was passed with nothing' from 'the file does not exist', giving an actionable message early.","triggerScenarios":"Calling read_target_list_file(''), read_target_list_file('   '), or a CLI invocation where --target-list's value came from an unset shell/env variable.","commonSituations":"CI YAML like --target-list ${TARGETS_FILE} with the variable unset; a wrapper script echoing an empty default; a stray flag with no argument followed by another flag.","solutions":["Provide a real path: --target-list targets.txt pointing to a UTF-8 file with one target per line.","In scripts, default the variable: TARGETS_FILE=${TARGETS_FILE:-targets.txt}.","Verify the file exists and contains uncommented target lines before the run."],"exampleFix":"# before\nstrix -n --target-list \"$TARGETS_FILE\"   # unset -> empty string\n\n# after\nTARGETS_FILE=\"${TARGETS_FILE:-targets.txt}\"\nstrix -n --target-list \"$TARGETS_FILE\"","handlingStrategy":"validation","validationCode":"path_str = (path_str or \"\").strip()\nif not path_str:\n    raise SystemExit(\"--target-list requires a file path\")\ntargets = read_target_list_file(path_str)","typeGuard":"def is_non_empty_path_str(s: object) -> bool:\n    return isinstance(s, str) and bool(s.strip())","tryCatchPattern":"try:\n    targets = read_target_list_file(path_str)\nexcept ValueError as e:\n    if \"must not be empty\" in str(e):\n        raise SystemExit(\"Provide --target-list <file> with one target per line\") from e\n    raise","preventionTips":["Default --target-list variables to a known file in scripts: ${TARGETS_FILE:-targets.txt}","Fail CI jobs early when configuration variables are unset"],"tags":["validation","cli","targets","configuration"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}