xai-org/x-algorithm · error · RuntimeError

WilyNS returned no entries for {self._wily_path}

Error message

WilyNS returned no entries for {self._wily_path}

What it means

When resolving via WilyNS, the client GETs the discovery endpoint and expects a JSON 'entries' list of {addr, port} records; it randomly picks one. If entries is empty, there is no instance to route to and it raises RuntimeError naming the wily_path. The HTTP call itself succeeded — the service simply has no registered instances.

Source

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

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

    async def _resolve_wilyns(self) -> str:
        path = self._encode_lookup_path(self._wily_path)
        wilyns_url = f"https://wilyns-{self._zone}.twitter.biz"
        context = f"/p/static/{self._zone}/{self._role}/{self._client_name}/0/{int(time.time())}"
        async with httpx.AsyncClient() as tmp:
            resp = await tmp.get(
                f"{wilyns_url}/lookups/{path}",
                params={"context": context},
                timeout=10.0,
            )
            resp.raise_for_status()
            entries = resp.json().get("entries", [])
            if not entries:
                raise RuntimeError(f"WilyNS returned no entries for {self._wily_path}")
            entry = random.choice(entries)
            url = f"http://{entry['addr']}:{entry['port']}"
            return url

    async def _resolve(self) -> str:
        if self._static_url:
            logger.info("%s: using static URL %s", self._name, self._static_url)
            return self._static_url
        url = await self._resolve_wilyns()
        logger.info(
            "%s: resolved via WilyNS %s -> %s", self._name, self._wily_path, url
        )
        return url

    async def _build_client(self):
        old_client = self._client
        self._base_url = await self._resolve()
        self._client = httpx.AsyncClient(base_url=self._base_url, timeout=self._timeout)

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Verify the target service has running instances and they are registered in WilyNS (check the service's health/registration).
  2. Double-check the wily_path string (role/env segment typos lead to empty pools).
  3. Retry after instances come up; treat empty entries as transient and back off.
  4. If the service is expected to exist, fall back to static_url addressing while discovery repopulates.

Example fix

# before
client = WilyHttpClient(wily_path='prod/ads/recs')
url = await client._resolve()  # RuntimeError: no entries

# after
client = WilyHttpClient(
    wily_path='prod/ads/recs',
    static_url='http://recs-fallback:8080',  # optional fallback path
)
Defensive patterns

Strategy: retry

Validate before calling

# pre-check instance availability if a discovery query helper exists
entries = await wilyns_lookup(wily_path)
if not entries:
    logger.warning('no instances for %s; will retry', wily_path)

Try / catch

for delay in (1, 2, 5):
    try:
        resp = await client.get(path)
        break
    except RuntimeError as e:
        if 'no entries' not in str(e):
            raise
        await asyncio.sleep(delay)
else:
    raise RuntimeError(f'WilyNS pool stayed empty for {wily_path}')

Prevention

When it happens

Trigger: Calling an endpoint on a WilyHttpClient constructed with wily_path where WilyNS returns 200 with {"entries": []} — the service exists as a path but has zero live/registered instances.

Common situations: All instances of the target service are down or scaled to zero; service just deployed and not yet registered; environment/namespace mismatch so you query a path with no instances; stale wily_path typo that still resolves but to an empty pool.

Related errors


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