{"record":{"id":"9f6dea7e58ef45a1","repo":"twentyhq/twenty","slug":"app-registration-exists-but-could-not-be-found","errorCode":null,"errorMessage":"App registration exists but could not be found: ${app.universalIdentifier}","messagePattern":"App registration exists but could not be found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-sdk/src/cli/utilities/auth/ensure-app-registration.ts","lineNumber":57,"sourceCode":"  );\n\n  if (!isAlreadyClaimed) {\n    const errorDetail =\n      createResult.error instanceof Error\n        ? createResult.error.message\n        : ((createResult.error as { message?: string })?.message ??\n          String(createResult.error));\n\n    throw new Error(`Failed to create app registration: ${errorDetail}`);\n  }\n\n  const findResult =\n    await apiService.findApplicationRegistrationByUniversalIdentifier(\n      app.universalIdentifier,\n    );\n\n  if (!findResult.success || !findResult.data) {\n    throw new Error(\n      `App registration exists but could not be found: ${app.universalIdentifier}`,\n    );\n  }\n\n  const registration = findResult.data;\n\n  await configService.setConfig({\n    appRegistrationId: registration.id,\n    appRegistrationClientId: registration.oAuthClientId,\n    appAccessToken: undefined,\n    appRefreshToken: undefined,\n  });\n\n  // The registration may be a catalog-synced npm app owned by another (or no)\n  // workspace, so rotating its shared client secret is neither allowed nor\n  // desirable. Dev mode mints workspace-scoped app tokens via the\n  // generateApplicationToken mutation instead.\n  return {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-sdk/src/cli/utilities/auth/ensure-app-registration.ts#L39-L75","documentation":"Thrown by ensureAppRegistration in a narrow edge case: the create mutation returned UNIVERSAL_IDENTIFIER_ALREADY_CLAIMED (meaning a registration with this universalIdentifier exists on the server), but the subsequent findApplicationRegistrationByUniversalIdentifier query failed or returned no data. The registration supposedly exists but cannot be retrieved.","triggerScenarios":"After the 'already claimed' sub-code, the code calls findApplicationRegistrationByUniversalIdentifier. If that call returns { success: false } or { data: null/falsy }, this error fires. This indicates a race condition, eventual-consistency lag, permission issue, or data inconsistency on the server.","commonSituations":"Another process or team member just claimed the identifier on a different workspace and replication lag means the find query hasn't caught up. The current authenticated session doesn't have read access to the workspace that owns the registration. The registration was deleted between the create attempt and the find query.","solutions":["Retry the command after a short delay — this is often a transient eventual-consistency issue.","Verify the authenticated user/workspace has access to the registration with the given universalIdentifier.","If the identifier belongs to a catalog-synced npm app owned by another workspace, ensure you are using the correct workspace credentials.","Contact the Twenty platform team if the registration persistently cannot be found despite the 'already claimed' response."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"const ensureWithRetry = async (\n  apiService: ApiService,\n  configService: ConfigService,\n  app: { name: string; universalIdentifier: string },\n  retries = 3,\n): Promise<ReturnType<typeof ensureAppRegistration>> => {\n  for (let attempt = 0; attempt <= retries; attempt++) {\n    try {\n      return await ensureAppRegistration(apiService, configService, app);\n    } catch (error) {\n      if (error instanceof Error && error.message.includes('could not be found') && attempt < retries) {\n        await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));\n        continue;\n      }\n      throw error;\n    }\n  }\n  throw new Error('unreachable');\n};","preventionTips":["Retry the command after a short delay — this is often a transient consistency issue.","Verify the workspace credentials have read access to the registration.","If persistent, contact the platform team to investigate the registration record."],"tags":["sdk-cli","registration","race-condition","graphql"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}