{"record":{"id":"6fe1a7328a8c3fa4","repo":"toeverything/AFFiNE","slug":"databaseblockerror","errorCode":"DatabaseBlockError","errorMessage":"Unknown view type: ${type}","messagePattern":"Unknown view type: (.+?)","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/database/src/data-source.ts","lineNumber":606,"sourceCode":"  viewDataGet(viewId: string): DataViewDataType | undefined {\n    return this.viewDataList$.value.find(data => data.id === viewId)!;\n  }\n\n  viewDataMoveTo(id: string, position: InsertToPosition): void {\n    moveViewTo(this._model, id, position);\n  }\n\n  viewDataUpdate<ViewData extends DataViewDataType>(\n    id: string,\n    updater: (data: ViewData) => Partial<ViewData>\n  ): void {\n    updateView(this._model, id, updater);\n  }\n\n  viewMetaGet(type: string): ViewMeta {\n    const view = databaseBlockViewMap[type];\n    if (!view) {\n      throw new BlockSuiteError(\n        ErrorCode.DatabaseBlockError,\n        `Unknown view type: ${type}`\n      );\n    }\n    return view;\n  }\n\n  viewMetaGetById(viewId: string): ViewMeta | undefined {\n    const view = this.viewDataGet(viewId);\n    if (!view) {\n      return;\n    }\n    return this.viewMetaGet(view.mode);\n  }\n}\n\nexport const databaseViewInitTemplate = (\n  datasource: DatabaseBlockDataSource,","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/affine/blocks/database/src/data-source.ts#L588-L624","documentation":"Thrown by DatabaseBlockDataSource.viewMetaGet(type) when the supplied view type string is not a key in databaseBlockViewMap. That map is built from viewPresets.tableViewMeta, kanbanViewMeta, and calendarViewMeta, so only their 'type' values are valid. The error code is DatabaseBlockError and is used whenever a view mode is resolved (e.g. viewMetaGetById resolves a view's mode through this method).","triggerScenarios":"Calling viewMetaGet(type) or viewMetaGetById(viewId) (which internally calls viewMetaGet(view.mode)) where type/view.mode is not 'table', 'kanban', or 'calendar'. Persisting or injecting a DataViewDataType with an unknown mode. Loading a doc whose database block view was created by a newer/older version with a view preset not registered here.","commonSituations":"Version skew: a doc saved by a version that registered an extra view preset (e.g. a gallery/timeline view) opened in a build that lacks it. Custom view presets added without being appended to databaseBlockViews. Programmatic snapshot injection with a fabricated mode string.","solutions":["Register the custom view preset in databaseBlockViews (database/src/views/index.ts) so its type is present in databaseBlockViewMap.","Validate the view mode against the registered types before calling viewMetaGet; fall back to a known type (e.g. 'table') for unknown modes.","On version mismatch, run a migration that maps or removes unknown view modes from the block's views array."],"exampleFix":"// before\ndatasource.viewMetaGet(unknownMode); // throws DatabaseBlockError\n\n// after\nconst knownTypes = Object.keys(databaseBlockViewMap);\nconst mode = knownTypes.includes(storedMode) ? storedMode : 'table';\nconst meta = datasource.viewMetaGet(mode);","handlingStrategy":"validation","validationCode":"import { databaseBlockViewMap } from '@blocksuite/affine-block-database';\nconst known = Object.keys(databaseBlockViewMap);\nconst mode = known.includes(storedMode) ? storedMode : 'table';\ndatasource.viewMetaGet(mode);","typeGuard":"import { databaseBlockViewMap } from '@blocksuite/affine-block-database';\nfunction isKnownViewType(type: string): boolean {\n  return type in databaseBlockViewMap;\n}","tryCatchPattern":null,"preventionTips":["Register custom view presets in databaseBlockViews before use.","Validate persisted view.mode against registered types on load.","Migrate unknown view modes on version skew instead of throwing."],"tags":["database","view-meta","value-not-exists","version-skew"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}