usestrix/strix · error · ValueError
Invalid target '{target}': {e}
Error message
Invalid target '{target}': {e} What it means
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.
Source
Thrown at strix/interface/scan_setup.py:116
def build_targets_info(args: argparse.Namespace) -> None:
"""Populate ``args.targets_info`` from target/target-list inputs.
Raises :class:`ValueError` with a user-facing message on any bad input so
callers can surface it via ``parser.error`` (CLI) or a console panel (home
page).
"""
args.targets_info = []
targets = list(args.target or [])
for target_list_path in args.target_list or []:
targets.extend(read_target_list_file(target_list_path))
for target in targets:
try:
target_type, target_dict = infer_target_type(target)
except ValueError as e:
raise ValueError(f"Invalid target '{target}': {e}") from None
if target_type == "local_code":
display_target = target_dict.get("target_path", target)
else:
display_target = target
if target_type == "api_spec":
_resolve_api_spec(target, target_dict)
args.targets_info.append(
{"type": target_type, "details": target_dict, "original": display_target}
)
args.targets_info = dedupe_local_targets(args.targets_info)
assign_workspace_subdirs(args.targets_info)
rewrite_localhost_targets(args.targets_info, HOST_GATEWAY_HOSTNAME)
View on GitHub (pinned to 8551339130)
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.
Example fix
# before $ strix -n -t 'htp://example.com' # Invalid target # after $ strix -n -t 'https://example.com'
Defensive patterns
Strategy: validation
Validate before calling
from strix.utilities.target_inference import infer_target_type # module path per repo layout
for t in targets:
try:
infer_target_type(t)
except ValueError as e:
print(f'reject target early: {t} ({e})') Type guard
def is_valid_target(target: str) -> bool:
try:
infer_target_type(target)
except ValueError:
return False
return True Try / catch
from strix.interface.scan_setup import collect_targets_info # setup funnel
try:
collect_targets_info(args)
except ValueError as exc:
parser.error(str(exc)) # argparse prints usage + message, exits 2 Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- extra_system_prompt_context cannot override built-in scope k
- No target set. Add a target first.
- Unsupported scope mode: {scope_mode}
- Target must be a non-empty string
- Invalid target: {target} Target must be one of: - A valid UR
AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15).
Data as JSON: /api/errors/70e4d7728c4d3be3.
Report an issue: GitHub.