calcom/cal.diy · error · BadRequestException
Failed to get private links
Error message
Failed to get private links
What it means
The non-Error fallback in PrivateLinksService.getPrivateLinks' catch: if repo.listByEventTypeId or the transform rejects with a value that is not an Error instance, BadRequestException('Failed to get private links') is thrown as a generic message. As with error 395, the original cause is dropped from the response.
Source
Thrown at apps/api/v2/src/platform/event-types-private-links/services/private-links.service.ts:67
async getPrivateLinks(eventTypeId: number): Promise<PrivateLinkOutput[]> {
try {
const links = await this.repo.listByEventTypeId(eventTypeId);
const mapped: PrivateLinkData[] = links.map((l) => ({
id: l.link,
eventTypeId,
isExpired: isLinkExpired(l as any),
bookingUrl: `${process.env.NEXT_PUBLIC_WEBAPP_URL || "https://cal.com"}/d/${l.link}`,
expiresAt: l.expiresAt ?? null,
maxUsageCount: l.maxUsageCount ?? null,
usageCount: l.usageCount ?? 0,
}));
return this.outputService.transformArrayToOutput(mapped);
} catch (error) {
if (error instanceof Error) {
throw new BadRequestException(error.message);
}
throw new BadRequestException("Failed to get private links");
}
}
async updatePrivateLink(eventTypeId: number, input: UpdatePrivateLinkInput): Promise<PrivateLinkOutput> {
try {
const transformedInput = this.inputService.transformUpdateInput(input);
const updatedResult = await this.repo.update(eventTypeId, {
link: transformedInput.linkId,
expiresAt: transformedInput.expiresAt ?? null,
maxUsageCount: transformedInput.maxUsageCount ?? null,
});
if (!updatedResult || (updatedResult as any).count === 0) {
throw new NotFoundException("Updated link not found");
}
const updated = await this.repo.findWithEventTypeDetails(transformedInput.linkId);
if (!updated) throw new NotFoundException("Updated link not found");
const mapped: PrivateLinkData = {
id: updated.link,View on GitHub (pinned to 176037d0af)
Solutions
- Check the server logs for the original rejected value.
- Confirm the eventTypeId is valid and the table is reachable.
- If reproducible, log the caught value temporarily to identify the inner cause.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await privateLinksService.getPrivateLinks(eventTypeId);
} catch (e) {
if (e instanceof BadRequestException && e.message === 'Failed to get private links') {
// generic fallback; check server logs and DB connectivity
} else throw e;
} Prevention
- Treat the generic message as a server/DB fault, not a client error.
- Log the raw rejected value server-side to recover the cause.
- Retry once after confirming DB connectivity.
When it happens
Trigger: A Prisma rejection that isn't an Error instance on this code path; a non-Error thrown inside transformArrayToOutput; a DB connection drop; the output service throwing a plain object.
Common situations: DB outage during list; non-Error rejection from a dependency; legacy data that breaks the mapper in a way that throws a non-Error.
Related errors
- ${error.message}
- Failed to create private link
- Could not add ICS feeds, try using private ics feed.
- Either expiresAt or maxUsageCount must be provided
- Provide only one of expiresAt or maxUsageCount
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/d75e7ee54f7a7782.
Report an issue: GitHub.