{"record":{"id":"fcdc8b3fdf60d0b5","repo":"twentyhq/twenty","slug":"caller-failed-body-errors-map-error-e","errorCode":null,"errorMessage":"${caller}() failed: ${body.errors.map((error) => error.message).join(', ')}","messagePattern":"(.+?)\\(\\) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-sdk/src/sdk/logic-function/utils/post-graphql-request.util.ts","lineNumber":46,"sourceCode":"      'Content-Type': 'application/json',\n      Authorization: `Bearer ${accessToken}`,\n    },\n    body: JSON.stringify({ query, variables }),\n  });\n\n  if (!response.ok) {\n    throw new Error(\n      `${caller}() failed: HTTP ${response.status} ${response.statusText}`,\n    );\n  }\n\n  const body = (await response.json()) as {\n    data?: TData;\n    errors?: { message: string }[];\n  };\n\n  if (body.errors && body.errors.length > 0) {\n    throw new Error(\n      `${caller}() failed: ${body.errors.map((error) => error.message).join(', ')}`,\n    );\n  }\n\n  if (!body.data) {\n    throw new Error(`${caller}() failed: response contained no data.`);\n  }\n\n  return body.data;\n};\n","sourceCodeStart":28,"sourceCodeEnd":57,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-sdk/src/sdk/logic-function/utils/post-graphql-request.util.ts#L28-L57","documentation":"Thrown by postGraphqlRequest when the HTTP response is 200 OK but the GraphQL response body contains one or more errors. These are application-level GraphQL errors (validation failures, permission errors, not-found errors, etc.). All error messages are extracted and joined with commas for a consolidated error message.","triggerScenarios":"The metadata endpoint returns { data: null, errors: [{ message: '...' }] }. This covers: GraphQL validation errors (malformed query), permission/authorization errors (insufficient scopes), NOT_FOUND errors (resource doesn't exist), or any business-logic error the resolver throws.","commonSituations":"Querying for a connection/object that doesn't exist (returns NOT_FOUND). The app's access token lacks the required scopes for the operation. A GraphQL query has a syntax error or requests non-existent fields. A mutation violates server-side business rules (e.g. duplicate name).","solutions":["Read the error message(s) — they contain the specific GraphQL error from the resolver.","If the error mentions permissions/scopes: ensure the app registration has the required scopes granted.","If the error is NOT_FOUND: verify the resource ID exists and belongs to the current workspace.","If the error is a validation error: fix the input variables to match the schema.","Use the Postgres MCP or Twenty dev tools to verify the data exists server-side."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await postGraphqlRequest({ query, variables, caller: 'myAction' });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('myAction() failed:') && !error.message.includes('HTTP')) {\n    // GraphQL application-level error\n    const gqlErrors = error.message.replace('myAction() failed: ', '');\n    console.error('GraphQL errors:', gqlErrors);\n    if (gqlErrors.includes('NOT_FOUND')) {\n      handleNotFound();\n    } else if (gqlErrors.includes('permission') || gqlErrors.includes('FORBIDDEN')) {\n      handlePermissionError();\n    }\n    return;\n  }\n  throw error;\n}","preventionTips":["Validate input IDs exist before querying (use list operations to verify).","Ensure the app registration has all required scopes for operations.","Parse GraphQL error messages to distinguish NOT_FOUND, FORBIDDEN, and validation errors."],"tags":["sdk","graphql","api-error","validation"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}