siyuan-note/siyuan · error
View state ${name} must not be empty
Error message
View state ${name} must not be empty What it means
validateIdentityPart guard in the view-state service: one of the key identity components (scope, surface, or hostID) is empty, so a valid composite view-state key cannot be built. The named part in the message is the empty one.
Source
Thrown at app/src/util/viewState.ts:64
};
const defaultTransport: IViewStateTransport = {
async get(key) {
const {fetchSyncPost} = await import("./fetch");
const response = await fetchSyncPost("/api/storage/getViewState", {key});
checkResponse(response, "get");
return isViewStateData(response.data) ? response.data : {};
},
async patch(key, values, removeKeys) {
const {fetchSyncPost} = await import("./fetch");
const response = await fetchSyncPost("/api/storage/patchViewState", {key, values, removeKeys});
checkResponse(response, "patch");
},
};
const validateIdentityPart = (name: string, value: string) => {
if (!value) {
throw new Error(`View state ${name} must not be empty`);
}
};
const validateField = (field: string) => {
if (!field || field.length > 2048) {
throw new Error("Invalid view state field");
}
};
export const getViewStateKey = (identity: IViewStateIdentity) => {
validateIdentityPart("scope", identity.scope);
validateIdentityPart("surface", identity.surface);
validateIdentityPart("hostID", identity.hostID);
const key = [identity.scope, identity.surface, identity.hostID].map(encodeURIComponent).join(":");
if (key.length > 1024) {
throw new Error("View state key is too long");
}
return key;View on GitHub (pinned to 8641553a1f)
Solutions
- Supply non-empty scope, surface, and hostID when requesting a view-state key
- Check callers that derive hostID from block or layout IDs for empty values
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/src/util/viewState.ts:64 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/917e5def8b2cdc5e.
Report an issue: GitHub.