{"record":{"id":"c6d55116131542f6","repo":"hcengineering/platform","slug":"integrationsecretnotfound","errorCode":"IntegrationSecretNotFound","errorMessage":"IntegrationSecretNotFound","messagePattern":"IntegrationSecretNotFound","errorType":"exception","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"server/account/src/serviceOperations.ts","lineNumber":847,"sourceCode":"    kind == null ||\n    kind === '' ||\n    socialId == null ||\n    socialId === '' ||\n    workspaceUuid === undefined ||\n    key == null\n  ) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.BadRequest, {}))\n  }\n\n  const existingIntegration = await findExistingIntegration(account, db, params, extra)\n  if (existingIntegration == null) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.IntegrationNotFound, {}))\n  }\n\n  const secretKey: IntegrationSecretKey = { socialId, kind, workspaceUuid, key }\n  const existingSecret = await db.integrationSecret.findOne(secretKey)\n  if (existingSecret == null) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.IntegrationSecretNotFound, {}))\n  }\n\n  await db.integrationSecret.update(secretKey, { secret })\n}\n\nexport async function deleteIntegrationSecret (\n  ctx: MeasureContext,\n  db: AccountDB,\n  branding: Branding | null,\n  token: string,\n  params: IntegrationSecretKey\n): Promise<void> {\n  const { extra, account } = decodeTokenVerbose(ctx, token)\n  const { socialId, kind, workspaceUuid, key } = params\n  if (\n    kind == null ||\n    kind === '' ||\n    socialId == null ||","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/account/src/serviceOperations.ts#L829-L865","documentation":"updateIntegrationSecret looks up the existing secret by (socialId, kind, workspaceUuid, key) and throws IntegrationSecretNotFound when no record matches. The service only updates existing secrets; it never upserts.","triggerScenarios":"Calling updateIntegrationSecret for a key that was never added via addIntegrationSecret, or after the secret was already deleted.","commonSituations":"Key string mismatch (e.g. 'github-token' vs 'token'); secret stored under a different workspace; attempting update in a fresh environment where add was never run; double-delete race.","solutions":["Call addIntegrationSecret to create the secret if it should exist, or getIntegrationSecret first to confirm presence","Verify the exact `key` string matches the one used at creation time","Confirm the secret was not deleted by another process (check deleteIntegrationSecret callers)","Fall back to upsert logic: try get, add if missing, else update"],"exampleFix":"// before\nawait client.updateIntegrationSecret({ socialId, kind, workspaceUuid, key: 'token', secret })\n// after\nconst existing = await client.getIntegrationSecret({ socialId, kind, workspaceUuid, key: 'token' })\nif (existing == null) {\n  await client.addIntegrationSecret({ socialId, kind, workspaceUuid, key: 'token', secret })\n} else {\n  await client.updateIntegrationSecret({ socialId, kind, workspaceUuid, key: 'token', secret })\n}","handlingStrategy":"try-catch","validationCode":"const existing = await client.getIntegrationSecret({ socialId, kind, workspaceUuid, key })\nif (existing == null) throw new Error(`Secret '${key}' does not exist yet; use addIntegrationSecret`)","typeGuard":null,"tryCatchPattern":"try {\n  await client.updateIntegrationSecret(params)\n} catch (err) {\n  if (isStatusError(err, 'account.status.IntegrationSecretNotFound')) {\n    await client.addIntegrationSecret({ ...params }) // upsert fallback\n  } else { throw err }\n}","preventionTips":["Prefer get-then-add-or-update upsert flow","Keep secret key names in a shared constants module to avoid typos","Don't assume update creates missing records — it doesn't"],"tags":["account-service","integration-secret","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}