odysseus-dev/odysseus · error · ValueError
Invalid SSH remote host
Error message
Invalid SSH remote host
What it means
ValueError raised by _ssh_exec_argv while building an ssh command line. The remote specifier is validated for argument-injection: it must be non-empty, must not start with '-', and the host part (after the last '@') must be non-empty and not start with '-'. Any violation raises before ssh is invoked.
Source
Thrown at core/platform_compat.py:374
return path
except Exception:
pass
return None
def _ssh_exec_argv(
remote: str,
ssh_port: str | None,
*,
remote_cmd: str | None = None,
connect_timeout: int | None = None,
strict_host_key_checking: bool | None = None,
) -> list[str]:
"""Build a consistent ssh argv for remote command execution."""
remote_value = str(remote or "").strip()
remote_host = remote_value.rsplit("@", 1)[-1]
if not remote_value or remote_value.startswith("-") or not remote_host or remote_host.startswith("-"):
raise ValueError("Invalid SSH remote host")
argv = ["ssh"]
if connect_timeout is not None:
argv.extend(["-o", f"ConnectTimeout={int(connect_timeout)}"])
if strict_host_key_checking is not None:
argv.extend(
[
"-o",
"StrictHostKeyChecking=yes"
if strict_host_key_checking
else "StrictHostKeyChecking=no",
]
)
if ssh_port and ssh_port != "22":
argv.extend(["-p", str(ssh_port)])
argv.append(remote)
if remote_cmd is not None:
argv.append(remote_cmd)
return argvView on GitHub (pinned to f9235ebbf1)
Solutions
- Set the remote to a well-formed 'user@host' or 'host' string
- Strip whitespace and reject leading '-' in the config/UI before calling
- Quote nothing — this is argv-based; just avoid dashes at the start of the host
- If the host genuinely starts with a digit-letter name, ensure no leading '-' or use an ssh config alias
Example fix
# before
remote = cfg.get('ssh_remote', '') # '' passes into _ssh_exec_argv → ValueError
# after
remote = (cfg.get('ssh_remote') or '').strip()
if not remote or remote.startswith('-'):
raise ValueError('SSH remote must be set to user@host') Defensive patterns
Strategy: validation
Validate before calling
def is_valid_ssh_remote(remote: str) -> bool:
v = str(remote or '').strip()
host = v.rsplit('@', 1)[-1]
return bool(v) and not v.startswith('-') and bool(host) and not host.startswith('-') Try / catch
try:
argv = _ssh_exec_argv(remote, ssh_port)
except ValueError:
raise ConfigError(f'SSH remote {remote!r} is invalid — use user@host') from None Prevention
- Validate remote strings at config-load and UI-input time
- Never interpolate user input into shell/ssh option positions
- Reject empty strings early instead of relying on the deep raise
When it happens
Trigger: Passing remote='' or whitespace-only, a remote like '-oProxyCommand=...', 'user@-something', or '@hostwithemptyparts' (e.g. 'user@' or '@-flag') to any SSH remote-execution feature built on this helper.
Common situations: Empty SSH remote field in settings; user-entered remote beginning with a dash (treated as an ssh option); malformed user@host strings from config parsing; CI env vars with stray characters.
Related errors
- HTTP ${res.status}${body ? ': ' + body.slice(0, 160) : ''}
- Invalid remote_host — must be host or user@host, no SSH opti
- Invalid ssh_port
- Invalid local_dir — path segments cannot start with '-'
- Invalid pip package name
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/ddb576d36a430093.
Report an issue: GitHub.