{"record":{"id":"88083e81e8da6bc1","repo":"twentyhq/twenty","slug":"createcompany-did-not-return-an-id-88083e","errorCode":null,"errorMessage":"createCompany did not return an id","messagePattern":"createCompany did not return an id","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-apps/internal/twenty-partners/src/modules/partner/application-intake/services/find-or-create-company.service.ts","lineNumber":58,"sourceCode":"      );\n      if (match !== undefined) {\n        return match.node.id;\n      }\n      const pageInfo = existing.companies?.pageInfo;\n      cursor = pageInfo?.hasNextPage ? (pageInfo.endCursor ?? null) : null;\n    } while (cursor !== null);\n  }\n\n  const companyData: CoreSchema.CompanyCreateInput = {\n    name: input.companyName.trim(),\n  };\n  if (domain !== undefined) {\n    companyData.domainName = { primaryLinkUrl: domain };\n  }\n  const companyResult = await createCompany(client, companyData);\n  const companyId = companyResult.createCompany?.id;\n  if (companyId === undefined) {\n    throw new Error('createCompany did not return an id');\n  }\n  return companyId;\n}\n","sourceCodeStart":40,"sourceCodeEnd":62,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-apps/internal/twenty-partners/src/modules/partner/application-intake/services/find-or-create-company.service.ts#L40-L62","documentation":"findOrCreateCompanyId in the partner application-intake service guards the createCompany mutation result. After dedup-by-name and domain extraction, it calls createCompany and asserts createCompany.id. An undefined id means the server returned a null/id-less company payload rather than throwing.","triggerScenarios":"createCompany returns { createCompany: null } or no id. Causes: caller lacks Company create permission; companyName empty after trim; server-side validation; Company metadata out of sync; concurrent submission creating the same company leaving a race the dedup didn't catch.","commonSituations":"Partner application submitted with a whitespace-only companyName; role lacks Company create; manifest changed Company fields and metadata wasn't re-synced; duplicate application for an existing company created between the dedup lookup and the create.","solutions":["Inspect the raw createCompany response for null payload or errors array.","Validate input.companyName.trim() is non-empty before calling findOrCreateCompanyId.","Confirm the caller's role has Company create permission and Company is synced in metadata.","Reproduce createCompany in the GraphQL playground to read the server rejection."],"exampleFix":"// before\nconst companyResult = await createCompany(client, companyData);\nconst companyId = companyResult.createCompany?.id;\nif (companyId === undefined) {\n  throw new Error('createCompany did not return an id');\n}\n\n// after — guard the input and surface the result\nif (!input.companyName.trim()) {\n  throw new Error('companyName is required');\n}\nconst companyResult = await createCompany(client, companyData);\nconst companyId = companyResult.createCompany?.id;\nif (companyId === undefined) {\n  throw new Error(`createCompany did not return an id (result=${JSON.stringify(companyResult)})`);\n}","handlingStrategy":"type-guard","validationCode":"import { isNonEmptyString } from 'twenty-shared';\n\nif (!isNonEmptyString(input.companyName)) {\n  throw new Error('companyName is required');\n}\n// before findOrCreateCompanyId","typeGuard":"const hasCreatedCompanyId = (r: unknown): r is { createCompany: { id: string } } =>\n  typeof r === 'object' && r !== null &&\n  typeof (r as any).createCompany?.id === 'string';\n\nif (!hasCreatedCompanyId(companyResult)) {\n  throw new Error(`createCompany returned no id: ${JSON.stringify(companyResult)}`);\n}","tryCatchPattern":null,"preventionTips":["Validate companyName is non-empty before the create.","Always select and assert id on createCompany results.","Log the raw response when the id is missing to distinguish null payload from swallowed errors.","Confirm Company create permission and metadata sync."],"tags":["graphql","sdk","mutation","partners"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}