{"record":{"id":"794389ee02464134","repo":"calcom/cal.diy","slug":"updated-link-not-found","errorCode":null,"errorMessage":"Updated link not found","messagePattern":"Updated link not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/event-types-private-links/services/private-links.service.ts","lineNumber":80,"sourceCode":"      return this.outputService.transformArrayToOutput(mapped);\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new BadRequestException(error.message);\n      }\n      throw new BadRequestException(\"Failed to get private links\");\n    }\n  }\n\n  async updatePrivateLink(eventTypeId: number, input: UpdatePrivateLinkInput): Promise<PrivateLinkOutput> {\n    try {\n      const transformedInput = this.inputService.transformUpdateInput(input);\n      const updatedResult = await this.repo.update(eventTypeId, {\n        link: transformedInput.linkId,\n        expiresAt: transformedInput.expiresAt ?? null,\n        maxUsageCount: transformedInput.maxUsageCount ?? null,\n      });\n      if (!updatedResult || (updatedResult as any).count === 0) {\n        throw new NotFoundException(\"Updated link not found\");\n      }\n      const updated = await this.repo.findWithEventTypeDetails(transformedInput.linkId);\n      if (!updated) throw new NotFoundException(\"Updated link not found\");\n      const mapped: PrivateLinkData = {\n        id: updated.link,\n        eventTypeId,\n        isExpired: isLinkExpired(updated as any),\n        bookingUrl: `${process.env.NEXT_PUBLIC_WEBAPP_URL || \"https://cal.com\"}/d/${updated.link}`,\n        expiresAt: updated.expiresAt ?? null,\n        maxUsageCount: updated.maxUsageCount ?? null,\n        usageCount: updated.usageCount ?? 0,\n      };\n      return this.outputService.transformToOutput(mapped);\n    } catch (error) {\n      if (error instanceof Error) {\n        if (error.message.includes(\"not found\")) {\n          throw new NotFoundException(error.message);\n        }","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/event-types-private-links/services/private-links.service.ts#L62-L98","documentation":"First of two 'Updated link not found' guards in PrivateLinksService.updatePrivateLink. After repo.update returns, the result is checked: if it is falsy OR its (loosely-cast) `.count` is 0, NotFoundException is thrown: no row matched the (eventTypeId, link) pair, so nothing was updated. This is HTTP 404 because the targeted resource doesn't exist.","triggerScenarios":"PATCH /v2/event-types/{id}/private-links/{linkId} where linkId doesn't exist under that eventTypeId; the link was already deleted; the linkId is correct but belongs to a different eventTypeId; a typo or truncated linkId in the request.","commonSituations":"Stale client showing a link that was since deleted; cross-event-type confusion; copy-paste of a linkId with a trailing character stripped; concurrent delete between GET and PATCH.","solutions":["Verify the linkId exists for the given eventTypeId (GET /v2/event-types/{id}/private-links) before PATCHing.","Refresh the client's link list if it may be stale.","Treat a 404 on update as 'already gone' and refresh the list rather than retrying blindly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const links = await privateLinksService.getPrivateLinks(eventTypeId);\nconst exists = links.some(l => l.id === linkId);\nif (!exists) {\n  return { status: 'not_found' }; // refresh the client's list instead of PATCHing\n}","typeGuard":"function isExistingLinkId(links: { id: string }[], linkId: string): boolean {\n  return links.some(l => l.id === linkId);\n}","tryCatchPattern":"try {\n  await privateLinksService.updatePrivateLink(eventTypeId, input);\n} catch (e) {\n  if (e instanceof NotFoundException && e.message === 'Updated link not found') {\n    // refresh the link list; the linkId is stale or wrong\n  } else throw e;\n}","preventionTips":["Refresh the link list before allowing an update.","Match on the full linkId string (avoid truncation).","Treat 404 on update as 'already gone' and refresh."],"tags":["private-links","not-found","api-v2"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}