{"record":{"id":"255a928d68597188","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypecreated-id-not-foun","errorCode":null,"errorMessage":"Event type with id ${eventTypeCreated.id} not found","messagePattern":"Event type with id (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/event-types/event-types_2024_06_14/services/event-types.service.ts","lineNumber":71,"sourceCode":"        prisma: this.dbWrite.prisma,\n      },\n    });\n\n    await updateEventType({\n      input: {\n        id: eventTypeCreated.id,\n        ...body,\n      },\n      ctx: {\n        user: eventTypeUser,\n        prisma: this.dbWrite.prisma,\n      },\n    });\n\n    const eventType = await this.eventTypesRepository.getEventTypeById(eventTypeCreated.id);\n\n    if (!eventType) {\n      throw new NotFoundException(`Event type with id ${eventTypeCreated.id} not found`);\n    }\n\n    return {\n      ownerId: user.id,\n      ...eventType,\n    };\n  }\n\n  async getEventTypeByIdIfAuthorized(\n    authUser: ApiAuthGuardUser,\n    eventTypeId: number\n  ): Promise<DatabaseTeamEventType | ({ ownerId: number } & DatabaseEventType) | null> {\n    const eventType = await this.eventTypesRepository.getEventTypeByIdWithHosts(eventTypeId);\n\n    if (!eventType) {\n      return null;\n    }\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/event-types/event-types_2024_06_14/services/event-types.service.ts#L53-L89","documentation":"Thrown by EventTypesService_2024_06_14.createUserEventType (POST /v2/event-types, cal-api-version 2024-06-14) immediately after a create+update sequence, when the follow-up getEventTypeById returns null. The row was reportedly created and updated but cannot be re-read — a post-create consistency failure indicating a race, a transaction rollback, or a repository filter excluding the new row.","triggerScenarios":"createEventType succeeds and returns an id, then updateEventType runs, but the subsequent getEventTypeById returns null because: the create was rolled back by a downstream hook; the read replica lags; a Prisma transaction aborted after returning the id; the new row is filtered out by a soft-delete or org scope in getEventTypeById.","commonSituations":"Read-replica lag in a distributed deployment; an after-create hook that soft-deletes or moves the row; a transaction isolation level that hides uncommitted rows from the read client; a bug where createEventType returns a phantom id on validation failure.","solutions":["Retry the GET after a short delay to absorb read-replica lag.","Check whether the create actually persisted by listing the user's event types.","Inspect createEventType and updateEventType for transaction boundaries that may roll back after returning an id.","If reproducible, verify the read and write Prisma clients point at the same primary or a low-lag replica."],"exampleFix":"// before\nconst created = await api.post('/v2/event-types', body); // throws 404 internally\n// after\nlet created;\ntry {\n  created = await api.post('/v2/event-types', body);\n} catch (e) {\n  if (e.response?.status === 404) {\n    // likely read-after-write lag; verify via list\n    const list = (await api.get('/v2/event-types')).data;\n    created = list.find(e => e.slug === body.slug);\n  }\n  if (!created) throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await api.post('/v2/event-types', body, { headers: { 'cal-api-version': '2024-06-14' } });\n} catch (e) {\n  if (e.response?.status === 404) {\n    // post-create read failed; verify via list to avoid duplicate creates\n    const list = (await api.get('/v2/event-types', { headers: { 'cal-api-version': '2024-06-14' } })).data;\n    const found = list.find((x) => x.slug === body.slug);\n    if (found) return found;\n  }\n  throw e;\n}","preventionTips":["On a 404 from create, list event types before retrying to avoid duplicate rows.","If using read replicas, accept that post-create reads may lag — build in a single retry.","Inspect createEventType/updateEventType transaction boundaries if this is reproducible."],"tags":["nestjs","not-found","event-types","race-condition","cal-api-version"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}