Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python/openshell/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ def from_active_cluster(
/ cluster_name
/ "metadata.json"
)
metadata = json.loads(metadata_path.read_text())
try:
metadata = json.loads(metadata_path.read_text())
except FileNotFoundError:
raise SandboxError(f"gateway '{cluster_name}' not found") from None
if "gateway_endpoint" not in metadata:
raise SandboxError(f"gateway '{cluster_name}' metadata missing endpoint")
parsed = urlparse(metadata["gateway_endpoint"])
host = parsed.hostname or "127.0.0.1"
port = parsed.port or (443 if parsed.scheme == "https" else 80)
Expand Down Expand Up @@ -613,7 +618,10 @@ def _resolve_active_cluster() -> str:
if env_gateway:
return env_gateway
active_file = _xdg_config_home() / "openshell" / "active_gateway"
value = active_file.read_text().strip()
try:
value = active_file.read_text().strip()
except FileNotFoundError:
raise SandboxError("no active gateway configured") from None
if value == "":
raise SandboxError("no active gateway configured")
return value
Loading