{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/model/view_state.go#L302-L338","documentation":"getViewStateStorage reads storage/view-state.json and checks the header's version field against the kernel's supported viewStateVersion (currently 1). If the on-disk file was written by a NEWER kernel with a higher version, loading is refused with this error rather than misinterpreting unknown fields. Lower versions load fine (forward compatible only).","triggerScenarios":"Downgrading SiYuan (or opening a workspace) with an older kernel after a newer version already wrote view-state.json with version > 1; a workspace shared between installations of different builds.","commonSituations":"Rolling back to a previous release; syncing a workspace between machines running different kernel versions; test/dev builds writing a bumped version constant.","solutions":["Upgrade the kernel to the version that wrote the file (match the version that produced view-state.json)","Remove or archive data/storage/view-state.json to reset view state to empty (loses stored view states)","Restore a backup of view-state.json written by a compatible version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the on-disk version before loading\ndata, _ := os.ReadFile(filepath.Join(dataDir, \"storage\", \"view-state.json\"))\nvar header struct{ Version int `json:\"version\"` }\nif json.Unmarshal(data, &header) == nil && header.Version > 1 {\n    // kernel too old: upgrade before touching view state\n}","typeGuard":null,"tryCatchPattern":"if _, err := GetViewState(key); err != nil && strings.HasPrefix(err.Error(), \"unsupported view state version\") {\n    // stop using/overwriting view-state.json; upgrade the kernel or restore a compatible backup\n}","preventionTips":["Run the same (or newer) kernel version on all machines sharing a workspace","Back up view-state.json before downgrading SiYuan","Never hand-edit the version field in view-state.json"],"tags":["view-state","versioning","downgrade","compatibility"],"backgroundTag":"unsupported-operation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}