{"record":{"id":"1dec7e186f995fd2","repo":"different-ai/openwork","slug":"native-provider-client-response-was-incomplete","errorCode":null,"errorMessage":"Native provider client response was incomplete.","messagePattern":"Native provider client response was incomplete\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx","lineNumber":1001,"sourceCode":"  clientId?: string;\n  clientSecret?: string;\n  tenantId?: string;\n  features: string[];\n};\n\nexport type NativeProviderClient = {\n  providerId: string;\n  configured: boolean;\n  clientId: string | null;\n  tenantId: string | null;\n  features: string[];\n  scopes: string[];\n  redirectUri: string;\n};\n\nfunction parseNativeProviderClient(payload: unknown): NativeProviderClient {\n  if (!isRecord(payload)) {\n    throw new Error(\"Native provider client response was incomplete.\");\n  }\n  const { providerId, configured, clientId, tenantId, features, scopes, redirectUri } = payload;\n  if (\n    typeof providerId !== \"string\"\n    || typeof configured !== \"boolean\"\n    || (typeof clientId !== \"string\" && clientId !== null)\n    || (typeof tenantId !== \"string\" && tenantId !== null)\n    || !isStringArray(features)\n    || !isStringArray(scopes)\n    || typeof redirectUri !== \"string\"\n  ) {\n    throw new Error(\"Native provider client response was incomplete.\");\n  }\n  return { providerId, configured, clientId, tenantId, features, scopes, redirectUri };\n}\n\n/**\n * Native providers are configured with an org OAuth","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx#L983-L1019","documentation":"parseNativeProviderClient validates the shape of the native-provider OAuth client payload before use. When the response is not a JSON object at all (null, array, string, empty body), it throws this error immediately. The sibling check at line 1013 covers individual field type mismatches.","triggerScenarios":"GET the native provider client endpoint returns 2xx with a non-object body: empty response, HTML error page behind a proxy, JSON array, or `null` literal.","commonSituations":"Reverse proxy/auth gateway returned an HTML login page with 200; server route returns 204/empty; misrouted request hit a non-API path; content-type confusion causing parsed payload to be a string.","solutions":["Log the raw payload before parseNativeProviderClient to see what the server actually returned","Check the fetch URL/route — an HTML 200 body usually means a redirect to a login page or SPA fallback","Verify the endpoint serializes a JSON object on success (not 204/empty)","Confirm authentication cookies/tokens are sent so the gateway doesn't substitute its own 200 response"],"exampleFix":"// before\nif (!isRecord(payload)) {\n  throw new Error(\"Native provider client response was incomplete.\");\n}\n// after\nif (!isRecord(payload)) {\n  throw new Error(`Native provider client response was not an object: ${JSON.stringify(payload).slice(0, 200)}`);\n}","handlingStrategy":"type-guard","validationCode":"const res = await fetch(url, { credentials: 'include' });\nconst ct = res.headers.get('content-type') ?? '';\nif (!ct.includes('application/json')) throw new Error(`expected JSON, got ${ct}`);\nconst payload = await res.json();","typeGuard":"function isRecord(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  const client = await fetchNativeProviderClient(providerId);\n} catch (e) {\n  showToast({ variant: 'error', title: 'Could not load OAuth client', description: e instanceof Error ? e.message : String(e) });\n}","preventionTips":["Always check content-type is application/json before parsing","Ensure auth cookies/tokens are attached so gateways don't return HTML 200s","Verify API routes aren't shadowed by SPA fallback redirects","Log raw payload on parse failure for diagnosis"],"tags":["validation","api-response","json-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}