toeverything/AFFiNE · error · GraphqlBadRequest
caldav_provider_not_found
caldav_provider_not_found
Error message
GraphQL bad request, code: caldav_provider_not_found, CalDAV provider is not available.
What it means
Thrown by the calendar service's CalDAV account discovery when CalDAV integration is enabled but the providerPresetId sent in the mutation input does not match any entry in config.calendar.caldav.providers. The server looks the preset up by exact id equality before it can build a CalDAV client, so any unknown or stale id is rejected as a GraphQL bad request with code 'caldav_provider_not_found'. It is purely a config/input mismatch, not a network failure.
Source
Thrown at packages/backend/server/src/plugins/calendar/service.ts:207
}
async linkCalDAVAccount(params: {
userId: string;
input: LinkCalDAVAccountInput;
}) {
const caldavConfig = this.config.calendar.caldav;
if (!caldavConfig?.enabled) {
throw new GraphqlBadRequest({
code: 'caldav_disabled',
message: 'CalDAV integration is not enabled.',
});
}
const preset = caldavConfig.providers.find(
provider => provider.id === params.input.providerPresetId
);
if (!preset) {
throw new GraphqlBadRequest({
code: 'caldav_provider_not_found',
message: 'CalDAV provider is not available.',
});
}
const provider = this.requireProvider(CalendarProviderName.CalDAV);
if (!('discoverAccount' in provider)) {
throw new GraphqlBadRequest({
code: 'caldav_provider_unavailable',
message: 'CalDAV provider is not configured.',
});
}
const discovery = await (
provider as CalendarProvider & {
discoverAccount: (input: {
preset: CalendarCalDAVProviderPreset;
username: string;View on GitHub (pinned to 591f874dad)
Solutions
- Inspect the server's calendar.caldav.providers config and copy the exact provider.id you want to use into providerPresetId.
- Re-fetch the provider preset list from the API the UI uses for the CalDAV dialog instead of hardcoding ids.
- After changing provider presets on the server, restart the backend and reload the client so both sides agree on the preset list.
- Verify CalDAV is actually enabled (calendar.caldav.enabled) first; if it is disabled you will instead get caldav_disabled.
Example fix
// before
discoverCalDAVAccount({ input: { providerPresetId: 'Fastmail', username, password } });
// after — use the exact id from config.calendar.caldav.providers
discoverCalDAVAccount({ input: { providerPresetId: 'fastmail', username, password } }); Defensive patterns
Strategy: validation
Validate before calling
const presets = await calendarClient.getCalDAVPresets(); // from server config
if (!presets.some(p => p.id === input.providerPresetId)) {
throw new Error(`Unknown CalDAV preset '${input.providerPresetId}'. Available: ${presets.map(p => p.id).join(', ')}`);
} Type guard
const isKnownPreset = (id: string, presets: { id: string }[]) =>
presets.some(p => p.id === id); Try / catch
try {
await discoverCalDAVAccount({ input: { providerPresetId, username, password } });
} catch (e) {
if (e?.extensions?.code === 'caldav_provider_not_found') {
await refreshPresetList(); // re-sync ids from server, re-prompt user
} else throw e;
} Prevention
- Always populate the preset picker from the live server config, never from hardcoded lists.
- Treat preset ids as opaque server-owned identifiers — never transform or guess them.
- Re-fetch presets after server config changes or upgrades.
When it happens
Trigger: Calling the CalDAV discoverAccount mutation with a providerPresetId that is not one of the configured preset ids (e.g. 'fastmail' when only 'nextcloud' is defined); the client cached a preset id from an older server config; a typo or trailing whitespace in the id; the operator removed/renamed a preset in the server config and clients still send the old id.
Common situations: Self-hosted deployments where the admin edited calendar.caldav.providers but did not restart or clients kept stale preset lists; frontends populated from docs defaults that differ from the deployed config; environments where CalDAV is enabled but the providers array is left empty.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- caldav_provider_unavailable
- caldav_invalid_url
- caldav_insecure_url
- calendar_provider_oauth_unsupported
- Invalid config for module [${module}] with key [${key}] Valu
AI-assisted analysis of toeverything/AFFiNE@591f874dad (2026-08-18).
Data as JSON: /api/errors/44e3992e8fc4454a.
Report an issue: GitHub.