toeverything/AFFiNE · error · Error
[Table(${table.name})]: Field '${key}' value '${val}' is not
Error message
[Table(${table.name})]: Field '${key}' value '${val}' is not valid. Expected one of [${field.values?.join(', ')}]. What it means
A DataTypeShouldMatch validator case for enum fields: the field's schema type is 'enum', but the value supplied is not included in field.values. It fires when the data object assigns a value outside the allowed enum set; the message interpolates the offending field, value, and the full list of permitted values from the schema.
Source
Thrown at packages/common/infra/src/orm/core/validators/data.ts:76
if (val === undefined) {
delete data[key];
continue;
}
if (val === null) {
if (!field.optional) {
throw new Error(
`[Table(${table.name})]: Field '${key}' is required but not set.`
);
}
continue;
}
const typeGet = inputType(val);
if (field.type === 'enum') {
if (!field.values?.includes(val)) {
throw new Error(
`[Table(${table.name})]: Field '${key}' value '${val}' is not valid. Expected one of [${field.values?.join(', ')}].`
);
}
} else if (!typeMatches(field.type, typeGet)) {
throw new Error(
`[Table(${table.name})]: Field '${key}' type mismatch. Expected ${field.type} got ${typeGet}.`
);
}
} else if (!table.isDocumentTable) {
// strict check field existence for normal table
throw new Error(
`[Table(${table.name})]: Field '${key}' is not defined but set in entity.`
);
}
}
},
},
DataTypeShouldExactlyMatch: {View on GitHub (pinned to b4c8548c09)
Solutions
- Use one of the allowed values listed in the error for this field.
- Fix typos or outdated enum values in the data being written.
- Update the schema's allowed values if a new value is legitimate.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/common/infra/src/orm/core/validators/data.ts:76 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/f4ce56f42c8356a7.
Report an issue: GitHub.