{"record":{"id":"fc0d380c84bee765","repo":"twentyhq/twenty","slug":"res-statustext-await-res-text","errorCode":null,"errorMessage":"${res.statusText}: ${await res.text()}","messagePattern":"\\$\\{res\\.statusText\\}: \\$\\{await res\\.text\\(\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts","lineNumber":53,"sourceCode":"                typeof headers == 'function' ? await headers() : headers\n            headersObject = headersObject || {}\n            if (typeof fetch === 'undefined' && !_fetch) {\n                throw new Error(\n                    'Global `fetch` function is not available, pass a fetch polyfill to Genql `createClient`',\n                )\n            }\n            let fetchImpl = _fetch || fetch\n            const res = await fetchImpl(url!, {\n                headers: {\n                    'Content-Type': 'application/json',\n                    ...headersObject,\n                },\n                method: 'POST',\n                body: JSON.stringify(body),\n                ...rest,\n            })\n            if (!res.ok) {\n                throw new Error(`${res.statusText}: ${await res.text()}`)\n            }\n            const json = await res.json()\n            return json\n        }\n    }\n\n    if (!batch) {\n        return async (body) => {\n            const json = await fetcher!(body)\n            if (Array.isArray(json)) {\n                return json.map((json) => {\n                    if (json?.errors?.length) {\n                        throw new GenqlError(json.errors || [], json.data)\n                    }\n                    return json.data\n                })\n            } else {\n                if (json?.errors?.length) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts#L35-L71","documentation":"Thrown by the Genql-generated fetcher inside twenty-client-sdk when the GraphQL endpoint returns a non-2xx HTTP status. The error message concatenates res.statusText with the raw response body (await res.text()), so the actual server error text is included. This is the genql runtime's lowest-level HTTP failure path before any JSON parsing is attempted.","triggerScenarios":"Calling any generated genql client query/mutation where the POST to the GraphQL URL receives res.ok === false (e.g. 401, 403, 404, 500, 502). The check at fetcher.ts:52 is `if (!res.ok)` and runs only for the single (non-batched) fetcher path.","commonSituations":"Wrong baseUrl passed to createClient; the Twenty server is down or behind a misconfigured proxy that returns HTML/JSON error pages; expired or missing Authorization token causing 401; CORS preflight failure surfacing as an opaque error response; hitting a path that is not the GraphQL endpoint.","solutions":["Inspect the full error message: the part after the colon is the raw server body — read it to get the real cause.","Verify the URL passed to the Twenty client (should point to the GraphQL endpoint, not the REST root).","Confirm the access token is valid and not expired; pass a fresh token via headers or the client constructor.","Check that the Twenty backend is reachable from the runtime environment (network/VPN/proxy/CORS)."],"exampleFix":"// before\nconst client = createClient({ url: 'https://app.twenty.com', headers: {} });\n// after\nconst client = createClient({\n  url: 'https://app.twenty.com/graphql',\n  headers: { Authorization: `Bearer ${process.env.TWENTY_ACCESS_TOKEN}` },\n});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await client.someQuery();\n} catch (err) {\n  // Genql raw HTTP error: `${statusText}: ${body}` — parse on the first colon\n  const [statusText, ...rest] = err.message.split(':');\n  console.error('GraphQL HTTP failure:', statusText.trim(), rest.join(':'));\n}","preventionTips":["Always pass a valid baseUrl pointing to the GraphQL endpoint.","Inject a fresh Authorization token before constructing the client.","Verify server reachability from the runtime environment before calling.","Log the raw response body to diagnose gateway/CDN error pages."],"tags":["network","graphql","authentication","client-sdk"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}