usestrix/strix · error · ValueError
Target must be a non-empty string
Error message
Target must be a non-empty string
What it means
infer_target_type requires a non-empty string target and raises immediately for empty strings, whitespace-only strings (they survive this check but fail later), or non-string values like None. It is the router that classifies a raw --target value into repository/postman/api_spec/local_code/web_application, so it must have real text to parse.
Source
Thrown at strix/interface/utils.py:1115
instruction_block=instruction_block,
metadata=metadata,
)
def _is_http_git_repo(url: str) -> bool:
check_url = f"{url.rstrip('/')}/info/refs?service=git-upload-pack"
try:
with requests.get(check_url, headers={"User-Agent": "git/2.43.0"}, timeout=10) as resp:
if resp.status_code >= 400:
return resp.status_code == 401
return "x-git-upload-pack-advertisement" in resp.headers.get("Content-Type", "")
except (requests.RequestException, ValueError):
return False
def infer_target_type(target: str) -> tuple[str, dict[str, str]]: # noqa: PLR0911
if not target or not isinstance(target, str):
raise ValueError("Target must be a non-empty string")
target = target.strip()
if target.startswith("git@"):
return "repository", {"target_repo": target}
if target.startswith("git://"):
return "repository", {"target_repo": target}
parsed = urlparse(target)
if parsed.scheme == "postman":
collection_uid = f"{parsed.netloc}{parsed.path}".strip("/")
if not collection_uid:
raise ValueError(
f"Missing Postman collection id in '{target}' (expected postman://<collection-uid>)"
)
details = {
"target_spec": target,View on GitHub (pinned to 8551339130)
Solutions
- Pass a non-empty target string, e.g. a URL, git@... SSH target, postman:// id, or local path.
- In scripts, guard with a check like [ -n "$TARGET" ] before invoking strix.
- If the value may be a Path, convert with str(path) before calling.
Example fix
# before
result = infer_target_type(os.environ.get("SCAN_TARGET")) # None when unset
# after
target = os.environ.get("SCAN_TARGET") or ""
if not target.strip():
raise SystemExit("SCAN_TARGET is not set")
result = infer_target_type(target) Defensive patterns
Strategy: type-guard
Validate before calling
target = target.strip() if isinstance(target, str) else ""
if not target:
raise SystemExit("A non-empty --target is required")
result = infer_target_type(target) Type guard
def is_non_empty_str(target: object) -> bool:
return isinstance(target, str) and bool(target.strip()) Try / catch
try:
ttype, details = infer_target_type(target)
except ValueError as e:
if str(e) == "Target must be a non-empty string":
raise SystemExit(f"Usage: provide a target. Got {target!r}") from e
raise Prevention
- Fail fast in wrapper scripts when target variables are unset
- Convert Path objects to str before passing
When it happens
Trigger: Calling infer_target_type('') or infer_target_type(None); a CLI invocation where the -t/--target argument was consumed from an environment variable or script variable that ended up empty.
Common situations: CI pipelines building the command dynamically with an unset variable ($TARGET empty); shell scripts where a variable expansion produced an empty string; passing a Path object instead of str.
Related errors
- Invalid target: {target} Target must be one of: - A valid UR
- --target-list path must not be empty.
- Target list file '{path_str}' is not an existing file.
- Invalid target '{target}': {e}
- Unsupported scope mode: {scope_mode}
AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15).
Data as JSON: /api/errors/bd6c60a4e637e0a8.
Report an issue: GitHub.