toeverything/AFFiNE · error · BlockSuiteError
DatabaseBlockError
DatabaseBlockError
Error message
View ${viewId} not found What it means
DataViewRootUILogic.createDataViewUILogic() looks up a view by id via viewManager.viewGet(viewId). If no view with that id exists in the data source it throws DatabaseBlockError. A view id is stale or refers to a view that was deleted.
Source
Thrown at blocksuite/affine/data-view/src/core/data-view.ts:67
data: {
view: SingleView;
rowId: string;
}
) => Promise<void>;
};
};
export class DataViewRootUILogic {
private get dataSource() {
return this.config.dataSource;
}
private get viewManager() {
return this.dataSource.viewManager;
}
private createDataViewUILogic(viewId: string): DataViewUILogicBase {
const view = this.viewManager.viewGet(viewId);
if (!view) {
throw new BlockSuiteError(
BlockSuiteError.ErrorCode.DatabaseBlockError,
`View ${viewId} not found`
);
}
const pcLogic = view.meta.renderer.pcLogic;
const mobileLogic = view.meta.renderer.mobileLogic;
const logic = (IS_MOBILE ? mobileLogic : pcLogic) ?? pcLogic;
return new (logic(view))(this, view);
}
private readonly _viewsCache = new Map<
string,
{ mode: string; logic: DataViewUILogicBase }
>();
private readonly views$ = computed(() => {
const viewDataList = this.dataSource.viewDataList$.value;View on GitHub (pinned to 26c515e050)
Solutions
- Validate the viewId against viewManager.views$/viewGet() before rendering.
- Fall back to a default/first view id when the requested one is missing.
- Clear stale persisted selection state when a view is removed.
Example fix
// before const logic = root.createDataViewUILogic(missingViewId); // throws // after const viewId = viewManager.viewGet(requestedId) ? requestedId : viewManager.defaultViewId; const logic = root.createDataViewUILogic(viewId);
Defensive patterns
Strategy: validation
Validate before calling
const view = viewManager.viewGet(viewId);
const safeId = view ? viewId : viewManager.views$.value[0]?.id;
if (!safeId) throw new Error('no views available'); Type guard
const viewExists = (vm: any, id: string): boolean => Boolean(vm.viewGet(id));
Prevention
- Validate viewId against the view list before rendering
- Clear persisted selection when a view is deleted
When it happens
Trigger: Rendering a data view with a viewId that is not present in the viewManager — e.g. a persisted selection pointing at a removed view, or a viewId passed before the view list finished loading.
Common situations: A user deleted a view but a stored reference (URL param, persisted state) still points to it; race between view creation and rendering; corrupted view metadata.
Related errors
AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12).
Data as JSON: /api/errors/b0633aacc2b976b8.
Report an issue: GitHub.