different-ai/openwork · error · Error

Den returned an invalid diagnostics configuration response.

Error message

Den returned an invalid diagnostics configuration response.

What it means

After a successful (2xx) GET /v1/diagnostics/egress, loadConfiguration validates the payload against egressDiagnosticConfigurationSchema with safeParse. If the payload doesn't match the expected shape (available, targetOrigin, missingConfiguration, etc.), it throws "Den returned an invalid diagnostics configuration response." This is a client-side contract check protecting the UI from malformed or unexpected server data.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/egress-diagnostics-card.tsx:108

  const [bearerTokenDraft, setBearerTokenDraft] = useState("");
  const [savingBearerToken, setSavingBearerToken] = useState(false);
  const [editingBearerToken, setEditingBearerToken] = useState(false);

  useEffect(() => {
    if (!canView) {
      setLoading(false);
      return;
    }
    let cancelled = false;
    async function loadConfiguration() {
      setLoading(true);
      try {
        const { response, payload } = await requestJson("/v1/diagnostics/egress", { method: "GET" }, 12_000);
        if (!response.ok) {
          throw new Error(getErrorMessage(payload, `Could not load egress diagnostics (${response.status}).`));
        }
        const parsed = egressDiagnosticConfigurationSchema.safeParse(payload);
        if (!parsed.success) throw new Error("Den returned an invalid diagnostics configuration response.");
        if (!cancelled) {
          setAvailable(parsed.data.available);
          setTargetOrigin(parsed.data.targetOrigin);
          setMissingConfiguration(parsed.data.missingConfiguration);
          setError(null);
        }
      } catch (loadError) {
        if (!cancelled) setError(loadError instanceof Error ? loadError.message : "Could not load egress diagnostics.");
      } finally {
        if (!cancelled) setLoading(false);
      }
    }
    void loadConfiguration();
    return () => { cancelled = true; };
  }, [canView]);

  useEffect(() => {
    if (!copied) return;

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Log/inspect the raw payload from GET /v1/diagnostics/egress and compare it against egressDiagnosticConfigurationSchema to find the mismatched field.
  2. Align versions: update the dashboard or Den server so both sides use the same diagnostics configuration schema.
  3. Check for a reverse proxy or captive portal returning 200 with non-JSON content and fix the proxy routing for /v1/*.
  4. Clear any CDN/proxy cache in front of the Den API and retry.

Example fix

// before (older Den server omits missingConfiguration)
// payload: { available: true, targetOrigin: "https://x" } -> safeParse fails

// after: upgrade Den so the 200 payload matches the schema
// payload: { available: true, targetOrigin: "https://x", missingConfiguration: [] }
Defensive patterns

Strategy: type-guard

Validate before calling

const payloadIsJsonObject =
  typeof payload === "object" && payload !== null && "available" in payload && "targetOrigin" in payload;
if (!payloadIsJsonObject) throw new Error("Unexpected diagnostics payload shape before schema parse.");

Type guard

function looksLikeEgressConfig(p: unknown): p is { available: boolean; targetOrigin: string; missingConfiguration?: unknown } {
  return typeof p === "object" && p !== null
    && "available" in p && typeof (p as { available: unknown }).available === "boolean"
    && "targetOrigin" in p && typeof (p as { targetOrigin: unknown }).targetOrigin === "string";
}

Try / catch

try {
  await loadConfiguration();
} catch (e) {
  if (e instanceof Error && e.message.includes("invalid diagnostics configuration")) {
    console.error("Contract mismatch on /v1/diagnostics/egress — check server version/proxy.", e);
    showError("Diagnostics data from Den is unreadable; verify server version.");
  } else throw e;
}

Prevention

When it happens

Trigger: The server returns 200 but the JSON body is not a valid diagnostics configuration: an HTML error page served as 200 by a proxy, an empty body, a different schema from an older/newer Den server, or a gateway (e.g. login portal) intercepting the route.

Common situations: Version skew between dashboard and Den server (schema drift); misconfigured reverse proxy answering 200 with HTML; authenticated Wi-Fi/captive portal injecting a page; a CDN cache serving a stale or wrong payload.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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