toeverything/AFFiNE · error
Path data ended short
Error message
Path data ended short
What it means
For schema fields of type 'enum', the validator checks the incoming value against field.values before any generic type check; a value not in that list is rejected with the full allowed set printed in the message. Enum validation accepts any JS type as candidate, including strings that are simply not members.
Solutions
- Use one of the listed values — the message prints exactly which are allowed
- If the new value is legitimate, add it to field.values in the table schema
- Share a single constant (e.g. const STATUS = [...] as const) between the schema and all callers so the lists cannot drift
Example fix
// before
table.insert({ data: { id: 'a1', status: 'archieved' } }); // typo
// after
table.insert({ data: { id: 'a1', status: 'archived' } });
// or extend the schema: status: { type: 'enum', values: ['active', 'archived'] } Defensive patterns
Strategy: validation
Validate before calling
const STATUS = ['active', 'archived'] as const;
// schema: status: { type: 'enum', values: [...STATUS] }
function assertEnum(value: string, values: readonly string[]) {
if (!values.includes(value)) {
throw new Error(`Invalid enum value '${value}'. Allowed: ${values.join(', ')}`);
}
}
assertEnum(payload.status, STATUS); Type guard
const isStatus = (v: unknown): v is (typeof STATUS)[number] => STATUS.includes(v as any);
Prevention
- Share one constant array between the table schema and all producers of the value
- Validate enum values at the boundary (form/API parse) before they reach the ORM
- Watch for case mismatches and typos; the error message lists the exact allowed set
When it happens
Trigger: Inserting status: 'archieved' (typo) against values ['active','archived']; a new enum member added to application code but not to the table schema; case mismatch ('Active' vs 'active'); numeric/string confusion when values are numbers.
Common situations: Schema drift after adding an enum variant; external API data carrying unexpected values; copy-pasted allowed-values lists missing one entry.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/46bb0fcb907dae40.
Report an issue: GitHub.
Appendix: source
Thrown at blocksuite/affine/blocks/surface/src/utils/path-data-parser/parser.ts:119
params[params.length] = +numbeToken.text;
} else {
throw new Error(
'Param not a number: ' + mode + ',' + numbeToken.text
);
}
}
if (typeof PARAMS[mode] === 'number') {
const segment: Segment = { key: mode, data: params };
segments.push(segment);
index += paramsCount;
token = tokens[index];
if (mode === 'M') mode = 'L';
if (mode === 'm') mode = 'l';
} else {
throw new Error('Bad segment: ' + mode);
}
} else {
throw new Error('Path data ended short');
}
}
return segments;
}
export function serialize(segments: Segment[]): string {
const tokens: (string | number)[] = [];
for (const { key, data } of segments) {
tokens.push(key);
switch (key) {
case 'C':
case 'c':
tokens.push(
data[0],
`${data[1]},`,
data[2],
`${data[3]},`,
data[4],View on GitHub (pinned to b4c8548c09)