{"record":{"id":"1b0e63d3964beb58","repo":"siyuan-note/siyuan","slug":"unsupported-view-state-version-d","errorCode":null,"errorMessage":"unsupported view state version %d","messagePattern":"unsupported view state version (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/view_state.go","lineNumber":320,"sourceCode":"\t}\n\tdataPath := filepath.Join(util.DataDir, \"storage\", \"view-state.json\")\n\tif !filelock.IsExist(dataPath) {\n\t\treturn\n\t}\n\n\tdata, err := filelock.ReadFile(dataPath)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"read storage [view-state] failed: %s\", err)\n\t\treturn nil, err\n\t}\n\theader := struct {\n\t\tVersion int `json:\"version\"`\n\t}{}\n\tif err = gulu.JSON.UnmarshalJSON(data, &header); err != nil {\n\t\treturn backupCorruptedViewState(dataPath, err)\n\t}\n\tif viewStateVersion < header.Version {\n\t\treturn nil, fmt.Errorf(\"unsupported view state version %d\", header.Version)\n\t}\n\tif err = gulu.JSON.UnmarshalJSON(data, ret); err != nil {\n\t\treturn backupCorruptedViewState(dataPath, err)\n\t}\n\tif nil == ret.Views {\n\t\tret.Views = map[string]*ViewState{}\n\t}\n\tfor key, state := range ret.Views {\n\t\tif nil == state {\n\t\t\tdelete(ret.Views, key)\n\t\t\tcontinue\n\t\t}\n\t\tif nil == state.Data {\n\t\t\tstate.Data = map[string]any{}\n\t\t}\n\t}\n\tpruneViewStates(ret.Views)\n\tfor _, state := range ret.Views {","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/view_state.go#L302-L338","documentation":"getViewStateStorage reads the persisted view-state JSON, peeks at its \"version\" header, and rejects any file whose version is newer than the version this kernel build understands (viewStateVersion). This forward-compatibility guard prevents misinterpreting a schema written by a newer SiYuan version.","triggerScenarios":"GetViewState, PatchViewState, or RemoveViewState loads the view-state storage file that was written by a newer kernel whose storage version header is greater than the current build's viewStateVersion.","commonSituations":"User downgraded SiYuan (or runs an older kernel binary) against data written by a newer version; or synced workspace data from a machine running a newer release.","solutions":["Upgrade SiYuan kernel/app to a version whose viewStateVersion is >= the version reported in the error.","Check the version field at the top of the view-state storage file to confirm which writer produced it.","If downgrade is intentional, accept that view states from the newer version cannot be read (they are preserved on disk, not corrupted)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await getViewState(id);\n} catch (e) {\n  if (String(e).includes(\"unsupported view state version\")) {\n    console.warn(\"View states written by a newer SiYuan version; upgrade to read them.\");\n  } else { throw e; }\n}","preventionTips":["Keep all SiYuan instances that share a workspace on the same or compatible version.","Avoid running an older kernel against data written by a newer release.","Note that this error means data is preserved, not lost — upgrading resolves it."],"tags":["versioning","forward-compatibility","persistence"],"backgroundTag":"unsupported-config-value","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"}