{"record":{"id":"70e4d7728c4d3be3","repo":"usestrix/strix","slug":"invalid-target-target-e","errorCode":null,"errorMessage":"Invalid target '{target}': {e}","messagePattern":"Invalid target '(.+?)': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/scan_setup.py","lineNumber":116,"sourceCode":"\n\ndef build_targets_info(args: argparse.Namespace) -> None:\n    \"\"\"Populate ``args.targets_info`` from target/target-list inputs.\n\n    Raises :class:`ValueError` with a user-facing message on any bad input so\n    callers can surface it via ``parser.error`` (CLI) or a console panel (home\n    page).\n    \"\"\"\n    args.targets_info = []\n    targets = list(args.target or [])\n    for target_list_path in args.target_list or []:\n        targets.extend(read_target_list_file(target_list_path))\n\n    for target in targets:\n        try:\n            target_type, target_dict = infer_target_type(target)\n        except ValueError as e:\n            raise ValueError(f\"Invalid target '{target}': {e}\") from None\n\n        if target_type == \"local_code\":\n            display_target = target_dict.get(\"target_path\", target)\n        else:\n            display_target = target\n\n        if target_type == \"api_spec\":\n            _resolve_api_spec(target, target_dict)\n\n        args.targets_info.append(\n            {\"type\": target_type, \"details\": target_dict, \"original\": display_target}\n        )\n\n    args.targets_info = dedupe_local_targets(args.targets_info)\n\n    assign_workspace_subdirs(args.targets_info)\n    rewrite_localhost_targets(args.targets_info, HOST_GATEWAY_HOSTNAME)\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/scan_setup.py#L98-L134","documentation":"Raised in target setup (strix/interface/scan_setup.py:116) when infer_target_type(target) rejects a target string with a ValueError; the original reason (bad URL, unresolvable path, unrecognized format) is re-raised with `from None` as a clean, user-facing message. This is the single funnel for validating CLI/-target-list entries before a scan is prepared.","triggerScenarios":"Passing -t with a malformed URL (e.g. 'htp:/example', missing host), a local_code path that does not exist, or a string matching no supported target grammar; or a --target-list file containing such lines (they are extended into the same loop).","commonSituations":"Typos in URLs/paths; forgetting the scheme (http(s):// vs bare host rules of the inferencer); target-list files with trailing junk, comments, or Windows paths; referencing directories that were moved/deleted.","solutions":["Read the wrapped reason in the message — it states exactly why infer_target_type rejected the string — and correct the target (fix scheme, hostname, or path).","For file paths, confirm the path exists and is readable from where strix runs; use absolute paths.","For target lists, inspect the file for stray lines/encoding issues (each line goes through the same validation).","Test quickly: `strix -t '<target>' --dry-run`-equivalent setup or call infer_target_type directly to iterate fast."],"exampleFix":"# before\n$ strix -n -t 'htp://example.com'   # Invalid target\n\n# after\n$ strix -n -t 'https://example.com'","handlingStrategy":"validation","validationCode":"from strix.utilities.target_inference import infer_target_type  # module path per repo layout\nfor t in targets:\n    try:\n        infer_target_type(t)\n    except ValueError as e:\n        print(f'reject target early: {t} ({e})')","typeGuard":"def is_valid_target(target: str) -> bool:\n    try:\n        infer_target_type(target)\n    except ValueError:\n        return False\n    return True","tryCatchPattern":"from strix.interface.scan_setup import collect_targets_info  # setup funnel\ntry:\n    collect_targets_info(args)\nexcept ValueError as exc:\n    parser.error(str(exc))  # argparse prints usage + message, exits 2","preventionTips":["Validate every --target and target-list line with infer_target_type before launch.","Use absolute paths for code targets and full schemes for URLs.","Keep target-list files one-target-per-line with no comments."],"tags":["target","validation","cli","setup"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}