decolua/9router · error

BFL: no polling_url returned

Error message

BFL: no polling_url returned

What it means

Thrown by the Black Forest Labs (FLUX) adapter's parseResponse (open-sse/handlers/imageProviders/blackForestLabs.js:27) when the submit response JSON contains no polling_url. BFL generation is asynchronous: the initial POST returns { polling_url } that the adapter polls until status is 'Ready'. Without a polling_url there is nothing to poll, so the adapter treats the response as invalid.

Source

Thrown at open-sse/handlers/imageProviders/blackForestLabs.js:27

  buildUrl: (model) => `${BASE_URL}/${model}`,
  buildHeaders: (creds) => {
    const key = creds?.apiKey || creds?.accessToken;
    return { "Content-Type": "application/json", "x-key": key };
  },
  buildBody: (_model, body) => {
    const req = { prompt: body.prompt };
    if (body.size) {
      const [w, h] = body.size.split("x").map(Number);
      if (w) req.width = w;
      if (h) req.height = h;
    }
    if (body.image) req.image_prompt = body.image;
    return req;
  },
  async parseResponse(response, { headers }) {
    const data = await response.json();
    const pollingUrl = data.polling_url;
    if (!pollingUrl) throw new Error("BFL: no polling_url returned");
    const deadline = Date.now() + POLL_TIMEOUT_MS;
    while (Date.now() < deadline) {
      await sleep(POLL_INTERVAL_MS);
      const r = await fetch(pollingUrl, { headers: { "x-key": headers["x-key"], "Accept": "application/json" } });
      if (!r.ok) throw new Error(`BFL status ${r.status}`);
      const s = await r.json();
      if (s.status === "Ready") return s;
      if (s.status === "Error" || s.status === "Failed") throw new Error(s.error || "BFL generation failed");
    }
    throw new Error("BFL polling timeout");
  },
  normalize: (responseBody) => {
    const sample = responseBody.result?.sample;
    if (sample) return { created: nowSec(), data: [{ url: sample }] };
    return { created: nowSec(), data: [] };
  },
};

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Check the actual response body (log data in parseResponse) — it usually contains the real BFL error; fix auth first: ensure the x-key header carries a valid BFL API key.
  2. Verify your BFL account has credits/quota at api.bfl.ai.
  3. Ensure no proxy/CDN is rewriting the response (compare with a direct curl POST to the same endpoint with the same headers).
  4. If BFL changed its API shape, update the adapter to read the new task-URL field.

Example fix

// before
const data = await response.json();
const pollingUrl = data.polling_url;
// after: surface the real error when polling_url is absent
const data = await response.json();
const pollingUrl = data.polling_url;
if (!pollingUrl) throw new Error(`BFL: no polling_url returned: ${JSON.stringify(data)}`);
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: verify the key authenticates before submitting a task
const probe = await fetch("https://api.bfl.ai/v1/my_account", { headers: { "x-key": key } });
if (!probe.ok) throw new Error(`BFL key invalid: ${probe.status}`);

Type guard

function isBflTaskResponse(data) {
  return data != null && typeof data === "object" && typeof data.polling_url === "string" && data.polling_url.startsWith("http");
}

Try / catch

try {
  const image = await generateImage({ provider: "black-forest-labs", prompt });
} catch (e) {
  if (/BFL: no polling_url returned/.test(e.message)) {
    logBflResponseForDebug(); // response JSON holds the real BFL error
    return fallbackImageProvider(prompt);
  }
  if (/BFL status 429/.test(e.message)) return backoffRetry(3);
  throw e;
}

Prevention

When it happens

Trigger: parseResponse is called after a submit POST to https://api.bfl.ai/.../{model} and response.json() parses but data.polling_url is undefined — e.g. BFL returned an error envelope ({ error: ..., status: 4xx }) with HTTP 200, or the response shape changed / a proxy or gateway intercepted and returned a non-BFL JSON body (login page JSON, rate-limit notice).

Common situations: Invalid or missing x-key so BFL responds with an error object instead of a task; account out of credits; a corporate proxy or the 9router's own error path returned JSON that isn't a BFL task response; BFL API version change renaming polling_url.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/3cf5b59d770f2ccc. Report an issue: GitHub.