calcom/cal.diy · error · NotFoundException
User with username "${username}" not found
Error message
User with username "${username}" not found What it means
Thrown by EventTypesService_2024_04_15.getEventTypesPublicByUsername (GET /v2/event-types/:username/public) when usersRepository.findByUsername returns null — no user exists with that username. The endpoint is public/unauthenticated, so the username is the only key and a miss is a hard 404.
Source
Thrown at apps/api/v2/src/platform/event-types/event-types_2024_04_15/services/event-types.service.ts:112
const eventType = await this.eventTypesRepository.getUserEventTypeForAtom(
user,
isUserOrganizationAdmin,
eventTypeId
);
if (!eventType) {
return null;
}
this.checkUserOwnsEventType(user.id, eventType.eventType);
return eventType as { eventType: EventTypeOutput };
}
async getEventTypesPublicByUsername(username: string): Promise<EventTypesPublic> {
const user = await this.usersRepository.findByUsername(username);
if (!user) {
throw new NotFoundException(`User with username "${username}" not found`);
}
return await getEventTypesPublic(user.id);
}
async createUserDefaultEventTypes(userId: number) {
const { sixtyMinutes, sixtyMinutesVideo, thirtyMinutes, thirtyMinutesVideo } = DEFAULT_EVENT_TYPES;
const defaultEventTypes = await Promise.all([
this.eventTypesRepository.createUserEventType(userId, thirtyMinutes),
this.eventTypesRepository.createUserEventType(userId, sixtyMinutes),
this.eventTypesRepository.createUserEventType(userId, thirtyMinutesVideo),
this.eventTypesRepository.createUserEventType(userId, sixtyMinutesVideo),
]);
return defaultEventTypes;
}
View on GitHub (pinned to 176037d0af)
Solutions
- Confirm the username via the authenticated GET /v2/event-types or the user profile endpoint before calling the public route.
- For organization users, supply the org context required by your deployment (subdomain or org query param).
- Normalize the username to lowercase only if the repository lookup is case-insensitive — otherwise preserve exact casing.
- Cache the list of valid usernames if you poll this endpoint frequently.
Example fix
// before
const list = await api.get(`/v2/event-types/${username}/public`);
// after
const profile = await api.get('/v2/me'); // confirms the authenticated user's username
if (profile.username !== username) throw new Error('username mismatch');
const list = await api.get(`/v2/event-types/${username}/public`); Defensive patterns
Strategy: validation
Validate before calling
// Confirm the username exists via an authenticated profile lookup
const me = await api.get('/v2/me');
if (me.username !== username) {
// either wrong user or not the authenticated user — check source of `username`
throw new Error(`username ${username} does not match an existing user`);
} Type guard
function isUsernameString(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
return await api.get(`/v2/event-types/${username}/public`);
} catch (e) {
if (e.response?.status === 404) {
// no such user — prompt the user to correct the username
} else throw e;
} Prevention
- Source usernames from authenticated endpoints rather than user input where possible.
- For org users, supply the correct org context (subdomain or query param).
- Avoid assuming case-insensitivity unless you have confirmed the DB collation.
When it happens
Trigger: GET /v2/event-types/janedoe/public where no user has username 'janedoe'; the username is correct but belongs to an organization and the org-scoped lookup requires a different path; username casing mismatch (the lookup may be case-sensitive depending on DB collation).
Common situations: Renamed or deleted users; typo in the username pulled from a URL or config; username includes the org prefix incorrectly; the user exists only in a different deployment (staging vs production).
Related errors
- Event type with id ${eventTypeId} not found
- ${err.message}
- Event type with id ${eventTypeId} not found
- Event type with ID=${eventTypeId} does not exist.
- Team with id ${teamId} not found
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/22fa330e329b15cb.
Report an issue: GitHub.