{"record":{"id":"46bb0fcb907dae40","repo":"toeverything/AFFiNE","slug":"path-data-ended-short","errorCode":null,"errorMessage":"Path data ended short","messagePattern":"Path data ended short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/surface/src/utils/path-data-parser/parser.ts","lineNumber":119,"sourceCode":"          params[params.length] = +numbeToken.text;\n        } else {\n          throw new Error(\n            'Param not a number: ' + mode + ',' + numbeToken.text\n          );\n        }\n      }\n      if (typeof PARAMS[mode] === 'number') {\n        const segment: Segment = { key: mode, data: params };\n        segments.push(segment);\n        index += paramsCount;\n        token = tokens[index];\n        if (mode === 'M') mode = 'L';\n        if (mode === 'm') mode = 'l';\n      } else {\n        throw new Error('Bad segment: ' + mode);\n      }\n    } else {\n      throw new Error('Path data ended short');\n    }\n  }\n  return segments;\n}\n\nexport function serialize(segments: Segment[]): string {\n  const tokens: (string | number)[] = [];\n  for (const { key, data } of segments) {\n    tokens.push(key);\n    switch (key) {\n      case 'C':\n      case 'c':\n        tokens.push(\n          data[0],\n          `${data[1]},`,\n          data[2],\n          `${data[3]},`,\n          data[4],","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/blocks/surface/src/utils/path-data-parser/parser.ts#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"Schema drift after adding an enum variant; external API data carrying unexpected values; copy-pasted allowed-values lists missing one entry.","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"],"exampleFix":"// before\ntable.insert({ data: { id: 'a1', status: 'archieved' } }); // typo\n\n// after\ntable.insert({ data: { id: 'a1', status: 'archived' } });\n// or extend the schema: status: { type: 'enum', values: ['active', 'archived'] }","handlingStrategy":"validation","validationCode":"const STATUS = ['active', 'archived'] as const;\n// schema: status: { type: 'enum', values: [...STATUS] }\n\nfunction assertEnum(value: string, values: readonly string[]) {\n  if (!values.includes(value)) {\n    throw new Error(`Invalid enum value '${value}'. Allowed: ${values.join(', ')}`);\n  }\n}\nassertEnum(payload.status, STATUS);","typeGuard":"const isStatus = (v: unknown): v is (typeof STATUS)[number] =>\n  STATUS.includes(v as any);","tryCatchPattern":null,"preventionTips":["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"],"tags":["orm","database","schema-validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}