Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix(python): raise SandboxError instead of FileNotFoundError or KeyError
  • Loading branch information
moezdil committed May 23, 2026
commit 68a2b53d612edd9907a4353cc51607dbc16cc0fe
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")
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")
if value == "":
raise SandboxError("no active gateway configured")
return value
Loading