{"record":{"id":"7654805aeccda165","repo":"toeverything/AFFiNE","slug":"table-not-found","errorCode":null,"errorMessage":"Table not found","messagePattern":"Table not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/common/infra/src/orm/core/adapters/yjs/db.ts","lineNumber":30,"sourceCode":"export class YjsDBAdapter implements DBAdapter {\n  tables: Map<string, TableAdapter> = new Map();\n  constructor(\n    db: DBSchemaBuilder,\n    private readonly provider: DocProvider\n  ) {\n    for (const [tableName, table] of Object.entries(db)) {\n      validators.validateYjsTableSchema(tableName, table);\n      const doc = this.provider.getDoc(tableName);\n\n      this.tables.set(tableName, new YjsTableAdapter(tableName, doc));\n    }\n  }\n\n  table(tableName: string) {\n    const table = this.tables.get(tableName);\n\n    if (!table) {\n      throw new Error('Table not found');\n    }\n\n    return table;\n  }\n}\n","sourceCodeStart":12,"sourceCodeEnd":36,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/common/infra/src/orm/core/adapters/yjs/db.ts#L12-L36","documentation":"A lookup guard in YjsDBAdapter.table: the adapter only pre-registers table adapters for schemas declared in the DBSchemaBuilder at construction time, so this fires when tableName has no entry in the tables Map — i.e. code asked for a table that was never defined in the schema. The faulting input is the tableName string passed to table().","triggerScenarios":"Thrown at packages/common/infra/src/orm/core/adapters/yjs/db.ts:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the table in the Yjs document before reading or writing records.","Verify the table name matches the one used at creation time.","Ensure the doc is synced/initialized so its tables are materialized."],"exampleFix":null,"handlingStrategy":"type-guard","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"}