{"record":{"id":"9a9c9a1a1ab05bbc","repo":"usestrix/strix","slug":"invalid-target-target-target-must-be-one-of","errorCode":null,"errorMessage":"Invalid target: {target}\nTarget must be one of:\n- A valid URL (http:// or https://)\n- A Git repository URL (https://host/org/repo or git@host:org/repo.git)\n- A local directory path\n- An API spec file (OpenAPI/Swagger .json/.yaml or a Postman collection)\n- A Postman collection by id (postman://<collection-uid>[?env=<environment-uid>], needs POSTMAN_API_KEY)\n- A domain name (e.g., example.com)\n- An IP address (e.g., 192.168.1.10)","messagePattern":"Invalid target: (.+?)\nTarget must be one of:\n- A valid URL \\(http:// or https://\\)\n- A Git repository URL \\(https://host/org/repo or git@host:org/repo\\.git\\)\n- A local directory path\n- An API spec file \\(OpenAPI/Swagger \\.json/\\.yaml or a Postman collection\\)\n- A Postman collection by id \\(postman://<collection-uid>\\[\\?env=<environment-uid>\\], needs POSTMAN_API_KEY\\)\n- A domain name \\(e\\.g\\., example\\.com\\)\n- An IP address \\(e\\.g\\., 192\\.168\\.1\\.10\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/utils.py","lineNumber":1195,"sourceCode":"        raise ValueError(f\"Invalid path: {target} - {e!s}\") from e\n\n    if target.endswith(\".git\"):\n        return \"repository\", {\"target_repo\": target}\n\n    if \"/\" in target:\n        host_part, _, path_part = target.partition(\"/\")\n        if \".\" in host_part and not host_part.startswith(\".\") and path_part:\n            full_url = f\"https://{target}\"\n            if _is_http_git_repo(full_url):\n                return \"repository\", {\"target_repo\": full_url}\n            return \"web_application\", {\"target_url\": full_url}\n\n    if \".\" in target and \"/\" not in target and not target.startswith(\".\"):\n        parts = target.split(\".\")\n        if len(parts) >= 2 and all(p and p.strip() for p in parts):\n            return \"web_application\", {\"target_url\": f\"https://{target}\"}\n\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","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/utils.py#L1177-L1213","documentation":"The final catch-all of infer_target_type: the string matched none of the recognized target shapes — no scheme, not an existing path, no '.git' suffix, no host/path split that looks like a repo URL, and no bare domain-like 'x.y' form. The long message enumerates every accepted target form, which doubles as the function's contract documentation.","triggerScenarios":"Passing strings like 'my project', 'localhost' (no dot, no scheme), 'http://' (empty host), '..hidden/config', or single-label hostnames with no TLD and no slash; also targets whose existing-path check failed earlier in the chain.","commonSituations":"Quoting mistakes in shells that turn a URL into two words; using localhost:8080 without a scheme; trailing whitespace already stripped but internal spaces remain; expecting a hostname with port like '192.168.1.10:8080' to parse (it hits the host/path split with ':' not '.').","solutions":["Give the target a scheme: use http://localhost:8080 or https://example.com instead of bare hostnames with ports.","For IP:port or host:port forms, include the scheme, since the bare 'host/path' heuristic requires a dotted host and a '/' separator.","For local code, pass an existing directory path; for repos, use a full https:// or git@ URL or a path ending in .git."],"exampleFix":"# before\nstrix -n -t localhost:8080\n\n# after\nstrix -n -t http://localhost:8080","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef looks_like_valid_target(t: str) -> bool:\n    t = t.strip()\n    if not t:\n        return False\n    p = urlparse(t)\n    if p.scheme in (\"http\", \"https\", \"git\"):\n        return bool(p.netloc)\n    if t.startswith((\"git@\", \"postman://\")):\n        return True\n    from pathlib import Path\n    return Path(t).expanduser().exists() or (\".\" in t.split(\"/\")[0])","typeGuard":null,"tryCatchPattern":"try:\n    ttype, details = infer_target_type(target)\nexcept ValueError as e:\n    if str(e).startswith(\"Invalid target:\"):\n        raise SystemExit(\"Target not recognized. Add a scheme (http(s)://), use a git URL, an existing dir, or a domain.\") from e\n    raise","preventionTips":["Always include the scheme for URLs and host:port targets","Validate target strings in pipeline config before the scan step"],"tags":["targets","validation","cli","urls"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}