toeverything/AFFiNE · error · Error
[Table(${table.name})]: Field '${key}' is not defined but se
Error message
[Table(${table.name})]: Field '${key}' is not defined but set in entity. What it means
A DataTypeShouldMatch validator case for unknown fields: the else-branch fires when data contains a key that has no corresponding field in table.schema, i.e. the entity payload sets a property the table never defined. The faulting input is the extra key in the data object; the message names the table and the unrecognized field.
Source
Thrown at packages/common/infra/src/orm/core/validators/data.ts:87
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: {
validate(table, data) {
const keys: Set<string> = new Set();
for (const key in data) {
const field = table.schema[key];
if (field) {
const val = data[key];
if (val === undefined || val === null) {
if (!field.optional) {
throw new Error(View on GitHub (pinned to b4c8548c09)
Solutions
- Remove the undefined field from the entity; only schema-declared fields may be set.
- Add the field to the table schema if it is intentionally stored.
- Check for typos in the field name or stale data from an older schema version.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/common/infra/src/orm/core/validators/data.ts:87 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/dfb60eee4cfe3a22.
Report an issue: GitHub.