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

  1. Read the error message(s) — they contain the specific GraphQL error from the resolver.
  2. If the error mentions permissions/scopes: ensure the app registration has the required scopes granted.
  3. If the error is NOT_FOUND: verify the resource ID exists and belongs to the current workspace.
  4. If the error is a validation error: fix the input variables to match the schema.
  5. 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

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


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/fcdc8b3fdf60d0b5. Report an issue: GitHub.