calcom/cal.diy · error · BadRequestException
Invalid type for booking field '${eventTypeBookingField.name
Error message
Invalid type for booking field '${eventTypeBookingField.name}'. Expected type ${expectedBookingFieldResponseValueType} (compatible with field type '${eventTypeBookingFieldType}'), but received ${bookingFieldResponseValueType}. What it means
Thrown at the end of the per-field validation switch as a fallback when isValidType is false for any booking field whose type was handled (string, number, boolean, select, multiselect, checkbox, radio, url). The message reports the expected JS type, the field's declared type, and the received type. BadRequestException (HTTP 400).
Source
Thrown at apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts:365
`Invalid option '${submittedValue}' for booking field '${
eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
}
break;
case "url":
expectedBookingFieldResponseValueType = "string";
isValidType = bookingFieldResponseValueType === "string";
break;
default:
// note(Lauris): by default pass the field if we have a missing "case" in the switch
isValidType = true;
break;
}
if (!isValidType) {
throw new BadRequestException(
`Invalid type for booking field '${eventTypeBookingField.name}'. Expected type ${expectedBookingFieldResponseValueType} (compatible with field type '${eventTypeBookingFieldType}'), but received ${bookingFieldResponseValueType}.`
);
}
}
}
return true;
}
private isValidSingleOptionValue(
bookingFieldResponseValue: string | number,
eventTypeBookingFieldOptions: string[]
): boolean {
if (eventTypeBookingFieldOptions.length === 0) {
// note(Lauris): If no options defined, cannot validate against them, so pass.
return true;
}
return eventTypeBookingFieldOptions.some((val) => val === String(bookingFieldResponseValue));View on GitHub (pinned to 176037d0af)
Solutions
- Coerce the value to the expected JS type before submitting (boolean -> true/false, array for multiselect/checkbox).
- Re-fetch the event type to confirm each field's type and align payload accordingly.
- Add a serialization layer that respects JSON types rather than form-encoded strings.
Example fix
// before — boolean field sent as string
const responses = { optIn: 'true' };
// after
const responses = { optIn: true }; Defensive patterns
Strategy: type-guard
Validate before calling
function coerceForType(value: unknown, type: string) {
switch (type) {
case 'boolean': return typeof value === 'boolean' ? value : Boolean(value);
case 'number': return typeof value === 'number' ? value : Number(value);
case 'multiselect': case 'checkbox': return Array.isArray(value) ? value : [value];
default: return typeof value === 'string' ? value : String(value);
}
} Type guard
function matchesExpected(value: unknown, type: string): boolean {
switch (type) {
case 'boolean': return typeof value === 'boolean';
case 'number': return typeof value === 'number';
case 'select': case 'radio': return typeof value === 'string' || typeof value === 'number';
case 'multiselect': case 'checkbox': return Array.isArray(value);
case 'url': return typeof value === 'string';
default: return true;
}
} Try / catch
try { await client.post('/v2/bookings', body); }
catch (e) {
if (e.status === 400 && /Invalid type for booking field/.test(e.message)) { /* coerce value, retry */ }
else throw e;
} Prevention
- Send JSON with native types (not form-encoded strings)
- Coerce form values to proper types before submission
- Map field type to expected JS type in a shared util
When it happens
Trigger: A booking field response has a runtime type that does not match the expected type for the field — e.g. sending a string for a boolean field, a number for an array field, or an object for a string field.
Common situations: Loosely-typed JSON payloads from integrations; sending 'true' (string) instead of true (boolean) for boolean fields; sending a single value instead of an array for multiselect/checkbox; form serialization converting types.
Related errors
- Team with slug ${body.teamSlug} not found
- Missing attendee phone number - it is required by the event
- Missing required booking field response: ${eventTypeBookingF
- Invalid option '${submittedValue}' for booking field '${even
- One or more invalid options for booking field '${eventTypeBo
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/869621fb3bdd510f.
Report an issue: GitHub.