{"record":{"id":"3042c1b6f1b82eef","repo":"SigNoz/signoz","slug":"couldn-t-create-cloud-integration-service-account","errorCode":null,"errorMessage":"couldn't create cloud integration service account: %w","messagePattern":"couldn't create cloud integration service account: %w","errorType":"http","errorClass":"basemodel.ApiError","httpStatus":500,"severity":"error","filePath":"ee/query-service/app/api/cloudIntegrations.go","lineNumber":142,"sourceCode":"\t\t\t\"couldn't create cloud integration PAT: %w\", err,\n\t\t))\n\t}\n\n\tfactorAPIKey, err = ah.Signoz.Modules.ServiceAccount.GetOrCreateFactorAPIKey(ctx, factorAPIKey)\n\tif err != nil {\n\t\treturn \"\", basemodel.InternalError(fmt.Errorf(\n\t\t\t\"couldn't create cloud integration PAT: %w\", err,\n\t\t))\n\t}\n\treturn factorAPIKey.Key, nil\n}\n\nfunc (ah *APIHandler) getOrCreateCloudIntegrationServiceAccount(ctx context.Context, orgId valuer.UUID) (*serviceaccounttypes.ServiceAccount, *basemodel.ApiError) {\n\tdomain := ah.Signoz.Modules.ServiceAccount.Config().Email.Domain\n\tcloudIntegrationServiceAccount := serviceaccounttypes.NewServiceAccount(\"integration\", domain, serviceaccounttypes.ServiceAccountStatusActive, orgId)\n\tcloudIntegrationServiceAccount, err := ah.Signoz.Modules.ServiceAccount.GetOrCreate(ctx, orgId, cloudIntegrationServiceAccount)\n\tif err != nil {\n\t\treturn nil, basemodel.InternalError(fmt.Errorf(\"couldn't create cloud integration service account: %w\", err))\n\t}\n\t_, err = ah.Signoz.Modules.ServiceAccount.SetRoleByName(ctx, orgId, cloudIntegrationServiceAccount.ID, authtypes.SigNozViewerRoleName)\n\tif err != nil {\n\t\treturn nil, basemodel.InternalError(fmt.Errorf(\"couldn't create cloud integration service account: %w\", err))\n\t}\n\n\treturn cloudIntegrationServiceAccount, nil\n}\n\nfunc (ah *APIHandler) getIngestionUrlAndSigNozAPIUrl(ctx context.Context, licenseKey string) (\n\tstring, *basemodel.ApiError,\n) {\n\t// TODO: remove this struct from here\n\ttype deploymentResponse struct {\n\t\tName        string `json:\"name\"`\n\t\tClusterInfo struct {\n\t\t\tRegion struct {\n\t\t\t\tDNS string `json:\"dns\"`","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/ee/query-service/app/api/cloudIntegrations.go#L124-L160","documentation":"Thrown when the ServiceAccount module's GetOrCreate call fails while creating (or fetching) the dedicated cloud-integration service account for an org. It is wrapped as an internal error, meaning the failure is on the server side (database or model layer), not caller input. The account is created with name 'integration' on the configured email domain and must be uniquely owned by the org.","triggerScenarios":"Calling the cloud integrations connection-params endpoint (getOrCreateCloudIntegrationFactorAPIKey -> getOrCreateCloudIntegrationServiceAccount) when the underlying DB insert/select fails: DB down, migration missing the service_accounts table, unique-constraint conflict on the integration account, or an invalid orgId.","commonSituations":"Misconfigured SIGNOZ_SERVICEACCOUNT_EMAIL_DOMAIN, pending/corrupt migrations, transient DB outage, or a partially-created service account left from a previous failed attempt.","solutions":["Check query-service logs for the wrapped %w cause (DB error) emitted alongside this message","Verify DB connectivity and that service account migrations ran","Confirm the org exists and the orgId passed is valid","Retry the request after fixing the underlying cause; GetOrCreate is idempotent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Capture the *basemodel.ApiError, check Typ == model.ErrorInternal, and surface the wrapped cause; retry idempotently once for transient DB errors.","preventionTips":["Keep service-account migrations applied before enabling cloud integrations","Monitor DB health alerts for the query-service","Log the wrapped %w cause whenever this internal error appears"],"tags":["service-account","database","cloud-integrations","internal-error"],"backgroundTag":"database-write-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}