different-ai/openwork · error

Endpoint test failed (${response.status}).

Error message

Endpoint test failed (${response.status}).

What it means

requestLlmProviderTestConnection posts to /v1/llm-providers/test-connection; if the HTTP response is not ok it throws with a server-provided message or the embedded status. This reports that the endpoint-test API call itself failed (as opposed to the tested endpoint failing its probe).

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/llm-provider-data.tsx:451

}

/**
 * Probe an OpenAI-compatible endpoint through den-api: heals common URL
 * mistakes and returns the model ids the endpoint actually serves.
 */
export async function requestLlmProviderTestConnection(input: {
  api: string;
  apiKey?: string;
  modelIds?: string[];
}) {
  const timeoutMs = input.modelIds?.length ? 60000 : 20000;
  const { response, payload } = await requestJson(
    `/v1/llm-providers/test-connection`,
    { method: "POST", body: JSON.stringify(input) },
    timeoutMs,
  );
  if (!response.ok) {
    throw new Error(getErrorMessage(payload, `Endpoint test failed (${response.status}).`));
  }
  const result = isRecord(payload) ? asProbeResult(payload.result) : null;
  if (!result) {
    throw new Error("Endpoint test returned an unexpected response.");
  }
  const verifications = isRecord(payload) && Array.isArray(payload.verifications)
    ? payload.verifications
        .map(asModelVerification)
        .filter((entry): entry is LlmProviderModelVerification => entry !== null)
    : [];
  return { ...result, verifications };
}

export async function requestLlmProviderCatalog(orgId: string) {
  const { response, payload } = await requestJson(`/v1/llm-provider-catalog`, { method: "GET" }, 20000);
  if (!response.ok) {
    throw new Error(getErrorMessage(payload, `Failed to load the provider catalog (${response.status}).`));
  }

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Read response.status and the server message to distinguish 400 vs 401/403 vs 5xx.
  2. Validate the form input (baseUrl, apiKey format) before submitting the test request.
  3. Confirm the den-api server version implements /v1/llm-providers/test-connection.
  4. Increase timeoutMs if the tested endpoint is legitimately slow, or check for proxy timeouts.
  5. Check server logs for the failing probe to find the underlying cause.

Example fix

// before
throw new Error(getErrorMessage(payload, `Endpoint test failed (${response.status}).`));
// after (surface status-specific guidance)
const detail = getErrorMessage(payload, `Endpoint test failed (${response.status}).`);
if (response.status === 401) throw new Error("Session expired — sign in again before testing endpoints.");
throw new Error(detail);
Defensive patterns

Strategy: try-catch

Validate before calling

// validate before calling
function canSubmitTest(input: { baseUrl: string; apiKey: string }): boolean {
  try { new URL(input.baseUrl); } catch { return false; }
  return input.apiKey.length > 0;
}

Try / catch

try {
  const result = await requestLlmProviderTestConnection(input, 20000);
} catch (err) {
  const msg = err instanceof Error ? err.message : String(err);
  if (msg.includes("(401)")) promptReauth();
  else if (msg.includes("(400)")) showFormError("Check the base URL and API key.");
  else showFormError(msg);
}

Prevention

When it happens

Trigger: POST /v1/llm-providers/test-connection returns non-2xx: 400 (invalid input body), 401/403 (session/permission issues), 404 (route absent on the server), 408/504 (timeout via proxy), 5xx (backend crash during probe).

Common situations: Testing a provider with a malformed API key/URL submitted in the form; user lacks admin rights in the org; frontend deployed against a server that lacks the test-connection route; long provider handshakes hitting the requestJson timeoutMs.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/a98bf8605a92b8a5. Report an issue: GitHub.