{"record":{"id":"dfb60eee4cfe3a22","repo":"toeverything/AFFiNE","slug":"table-table-name-field-key-is-not-defi","errorCode":null,"errorMessage":"[Table(${table.name})]: Field '${key}' is not defined but set in entity.","messagePattern":"\\[Table\\((.+?)\\)\\]: Field '(.+?)' is not defined but set in entity\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/common/infra/src/orm/core/validators/data.ts","lineNumber":87,"sourceCode":"            continue;\n          }\n\n          const typeGet = inputType(val);\n\n          if (field.type === 'enum') {\n            if (!field.values?.includes(val)) {\n              throw new Error(\n                `[Table(${table.name})]: Field '${key}' value '${val}' is not valid. Expected one of [${field.values?.join(', ')}].`\n              );\n            }\n          } else if (!typeMatches(field.type, typeGet)) {\n            throw new Error(\n              `[Table(${table.name})]: Field '${key}' type mismatch. Expected ${field.type} got ${typeGet}.`\n            );\n          }\n        } else if (!table.isDocumentTable) {\n          // strict check field existence for normal table\n          throw new Error(\n            `[Table(${table.name})]: Field '${key}' is not defined but set in entity.`\n          );\n        }\n      }\n    },\n  },\n  DataTypeShouldExactlyMatch: {\n    validate(table, data) {\n      const keys: Set<string> = new Set();\n\n      for (const key in data) {\n        const field = table.schema[key];\n        if (field) {\n          const val = data[key];\n\n          if (val === undefined || val === null) {\n            if (!field.optional) {\n              throw new Error(","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/common/infra/src/orm/core/validators/data.ts#L69-L105","documentation":"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.","triggerScenarios":"Thrown at packages/common/infra/src/orm/core/validators/data.ts:87 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}