{"record":{"id":"56caabb87369c549","repo":"siyuan-note/siyuan","slug":"invalid-view-state-field","errorCode":null,"errorMessage":"Invalid view state field","messagePattern":"Invalid view state field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/util/viewState.ts","lineNumber":70,"sourceCode":"        checkResponse(response, \"get\");\n        return isViewStateData(response.data) ? response.data : {};\n    },\n    async patch(key, values, removeKeys) {\n        const {fetchSyncPost} = await import(\"./fetch\");\n        const response = await fetchSyncPost(\"/api/storage/patchViewState\", {key, values, removeKeys});\n        checkResponse(response, \"patch\");\n    },\n};\n\nconst validateIdentityPart = (name: string, value: string) => {\n    if (!value) {\n        throw new Error(`View state ${name} must not be empty`);\n    }\n};\n\nconst validateField = (field: string) => {\n    if (!field || field.length > 2048) {\n        throw new Error(\"Invalid view state field\");\n    }\n};\n\nexport const getViewStateKey = (identity: IViewStateIdentity) => {\n    validateIdentityPart(\"scope\", identity.scope);\n    validateIdentityPart(\"surface\", identity.surface);\n    validateIdentityPart(\"hostID\", identity.hostID);\n    const key = [identity.scope, identity.surface, identity.hostID].map(encodeURIComponent).join(\":\");\n    if (key.length > 1024) {\n        throw new Error(\"View state key is too long\");\n    }\n    return key;\n};\n\nexport class ViewStateService {\n    public readonly key: string;\n    public readonly ready: Promise<void>;\n    private readonly data: TViewStateData = {};","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/src/util/viewState.ts#L52-L88","documentation":"validateField guard in the view-state service: a field name for stored view-state data is empty or longer than 2048 characters. Field keys index the persisted patch values, so oversized or blank keys are rejected.","triggerScenarios":"Thrown at app/src/util/viewState.ts:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use concise, non-empty field keys","Hash or truncate long generated field names below the 2048 limit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}