{"record":{"id":"c5fa1179bcf42566","repo":"xai-org/x-algorithm","slug":"name-either-wily-path-or-static-url-must-be-set","errorCode":null,"errorMessage":"{name}: either wily_path or static_url must be set","messagePattern":"(.+?): either wily_path or static_url must be set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"grox/libs/wily_cli/http_client.py","lineNumber":25,"sourceCode":"\nimport httpx\n\nlogger = logging.getLogger(__name__)\n\n\nclass WilyHttpClient:\n    def __init__(\n        self,\n        wily_path: str = \"\",\n        static_url: str = \"\",\n        zone: str = \"atla\",\n        name: str = \"service\",\n        timeout: float = 30.0,\n        role: str = \"ads\",\n        client_name: str = \"wily-http-client\",\n    ):\n        if not wily_path and not static_url:\n            raise ValueError(f\"{name}: either wily_path or static_url must be set\")\n        self._wily_path = wily_path\n        self._static_url = static_url\n        self._zone = zone\n        self._name = name\n        self._timeout = timeout\n        self._role = role\n        self._client_name = client_name\n        self._client: httpx.AsyncClient | None = None\n        self._base_url: str = \"\"\n        self._resolve_lock = asyncio.Lock()\n\n    @property\n    def base_url(self) -> str:\n        return self._base_url\n\n    @staticmethod\n    def _encode_lookup_path(wily_path: str) -> str:\n        path = unquote(wily_path.lstrip(\"/\"))","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/grox/libs/wily_cli/http_client.py#L7-L43","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass wily_path (the WilyNS service path) when running where WilyNS discovery is available.","Or pass static_url='http://host:port' for local/dev or direct addressing.","If both come from config, validate at load time that exactly the addressing you expect is present."],"exampleFix":"# before\nclient = WilyHttpClient()  # ValueError: either wily_path or static_url must be set\n\n# after\nclient = WilyHttpClient(wily_path='prod/ads/recommender')\n# or\nclient = WilyHttpClient(static_url='http://10.0.0.5:8080')","handlingStrategy":"validation","validationCode":"if not (wily_path or static_url):\n    raise SystemExit('WilyHttpClient needs wily_path or static_url')\nclient = WilyHttpClient(wily_path=wily_path, static_url=static_url)","typeGuard":null,"tryCatchPattern":"try:\n    client = WilyHttpClient(wily_path=wp, static_url=su)\nexcept ValueError as e:\n    if 'must be set' in str(e):\n        client = WilyHttpClient(static_url=DEFAULT_URL)\n    else:\n        raise","preventionTips":["Make service addressing an explicit required setting","Provide env-based defaults for dev (static_url) and prod (wily_path)","Fail fast in config loading rather than deep in HTTP calls"],"tags":["service-discovery","configuration","http-client","init-validation"],"backgroundTag":"missing-endpoint-config","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}