twentyhq/twenty · error · Error
${caller}() failed: ${body.errors.map((error) => error.messa
Error message
${caller}() failed: ${body.errors.map((error) => error.message).join(', ')} What it means
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.
Source
Thrown at packages/twenty-sdk/src/sdk/logic-function/utils/post-graphql-request.util.ts:46
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({ query, variables }),
});
if (!response.ok) {
throw new Error(
`${caller}() failed: HTTP ${response.status} ${response.statusText}`,
);
}
const body = (await response.json()) as {
data?: TData;
errors?: { message: string }[];
};
if (body.errors && body.errors.length > 0) {
throw new Error(
`${caller}() failed: ${body.errors.map((error) => error.message).join(', ')}`,
);
}
if (!body.data) {
throw new Error(`${caller}() failed: response contained no data.`);
}
return body.data;
};
View on GitHub (pinned to 1f5dd2bbd2)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const data = await postGraphqlRequest({ query, variables, caller: 'myAction' });
} catch (error) {
if (error instanceof Error && error.message.includes('myAction() failed:') && !error.message.includes('HTTP')) {
// GraphQL application-level error
const gqlErrors = error.message.replace('myAction() failed: ', '');
console.error('GraphQL errors:', gqlErrors);
if (gqlErrors.includes('NOT_FOUND')) {
handleNotFound();
} else if (gqlErrors.includes('permission') || gqlErrors.includes('FORBIDDEN')) {
handlePermissionError();
}
return;
}
throw error;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- createCompany did not return an id
- createPerson did not return an id
- createOpportunity did not return an id
- createOpportunity did not return an id
- createCompany did not return an id
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/fcdc8b3fdf60d0b5.
Report an issue: GitHub.