xai-org/x-algorithm · error · ValueError

{name}: either wily_path or static_url must be set

Error message

{name}: either wily_path or static_url must be set

What it means

The Wily HTTP client can resolve services two ways: via WilyNS service discovery using wily_path, or directly via static_url. __init__ requires at least one of them; both falsy means the client has no way to build a URL, so it raises ValueError immediately.

Source

Thrown at grox/libs/wily_cli/http_client.py:25

import httpx

logger = logging.getLogger(__name__)


class WilyHttpClient:
    def __init__(
        self,
        wily_path: str = "",
        static_url: str = "",
        zone: str = "atla",
        name: str = "service",
        timeout: float = 30.0,
        role: str = "ads",
        client_name: str = "wily-http-client",
    ):
        if not wily_path and not static_url:
            raise ValueError(f"{name}: either wily_path or static_url must be set")
        self._wily_path = wily_path
        self._static_url = static_url
        self._zone = zone
        self._name = name
        self._timeout = timeout
        self._role = role
        self._client_name = client_name
        self._client: httpx.AsyncClient | None = None
        self._base_url: str = ""
        self._resolve_lock = asyncio.Lock()

    @property
    def base_url(self) -> str:
        return self._base_url

    @staticmethod
    def _encode_lookup_path(wily_path: str) -> str:
        path = unquote(wily_path.lstrip("/"))

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Pass wily_path (the WilyNS service path) when running where WilyNS discovery is available.
  2. Or pass static_url='http://host:port' for local/dev or direct addressing.
  3. If both come from config, validate at load time that exactly the addressing you expect is present.

Example fix

# before
client = WilyHttpClient()  # ValueError: either wily_path or static_url must be set

# after
client = WilyHttpClient(wily_path='prod/ads/recommender')
# or
client = WilyHttpClient(static_url='http://10.0.0.5:8080')
Defensive patterns

Strategy: validation

Validate before calling

if not (wily_path or static_url):
    raise SystemExit('WilyHttpClient needs wily_path or static_url')
client = WilyHttpClient(wily_path=wily_path, static_url=static_url)

Try / catch

try:
    client = WilyHttpClient(wily_path=wp, static_url=su)
except ValueError as e:
    if 'must be set' in str(e):
        client = WilyHttpClient(static_url=DEFAULT_URL)
    else:
        raise

Prevention

When it happens

Trigger: Constructing the client with wily_path=None/'' and static_url=None/'' — e.g. instantiating with only name/zone/timeout kwargs and forgetting the addressing argument.

Common situations: Refactor adding the static_url option where old call sites relied on wily_path being passed positionally and it got dropped; config defaulting both to None for an environment that has neither WilyNS nor a direct URL configured.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/c5fa1179bcf42566. Report an issue: GitHub.