Skip to content

bug: FailedToOpenSocket when workspace lacks AI Gateway #116

@dgokeeffe

Description

@dgokeeffe

Problem

get_gateway_host() auto-constructs an AI Gateway URL from DATABRICKS_WORKSPACE_ID (always set on Databricks Apps) without checking if the gateway actually exists. Workspaces without AI Gateway enabled get a FailedToOpenSocket error from Claude Code (Bun runtime) when it tries to connect to the non-existent host.

The fallback to {DATABRICKS_HOST}/serving-endpoints/anthropic never triggers because the gateway URL is returned unconditionally.

Affected code

  • utils.py:get_gateway_host() — returns unreachable URL without probing
  • All setup scripts (setup_claude.py, setup_codex.py, setup_gemini.py, setup_opencode.py, setup_proxy.py) — inherit the bad URL

Fix

  • Probe auto-discovered gateway URLs with a 2s timeout GET before using them
  • Cache the result in _GATEWAY_RESOLVED env var so subprocesses skip re-probing
  • Add resolve_and_cache_gateway() helper called once at boot

PR: #114

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions