{"record":{"id":"f55072265741546b","repo":"siyuan-note/siyuan","slug":"read-only-mode","errorCode":null,"errorMessage":"read-only mode","messagePattern":"read-only mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/boot_appearance.go","lineNumber":214,"sourceCode":"// GetBootAppearance 返回当前可用的启动页外观，任何异常和安全模式下均回退默认。\nfunc GetBootAppearance() *BootAppearance {\n\tif util.SafeMode {\n\t\treturn &BootAppearance{Enabled: false}\n\t}\n\tselection, appearance, err := loadSelectedBootAppearance()\n\tif err != nil {\n\t\treturn &BootAppearance{Enabled: false}\n\t}\n\tif selection.Provider == \"\" || selection.Appearance == \"\" {\n\t\treturn &BootAppearance{Enabled: false}\n\t}\n\treturn appearance\n}\n\n// SetBootAppearance 校验并原子持久化启动页外观选择，两项均为空表示恢复默认。\nfunc SetBootAppearance(provider, appearanceID string) (ret BootAppearanceSelection, err error) {\n\tif util.ReadOnly {\n\t\treturn defaultBootAppearanceSelection(), errors.New(\"read-only mode\")\n\t}\n\tprovider = strings.TrimSpace(provider)\n\tappearanceID = strings.TrimSpace(appearanceID)\n\tret = defaultBootAppearanceSelection()\n\tif (provider == \"\") != (appearanceID == \"\") {\n\t\terr = errors.New(\"provider and appearance must both be empty or non-empty\")\n\t\treturn\n\t}\n\tif provider != \"\" {\n\t\tif !bazaar.IsValidPackageName(provider) || !isValidBootAppearanceID(appearanceID) {\n\t\t\terr = ErrBootAppearanceNotFound\n\t\t\treturn\n\t\t}\n\t\tif _, resolveErr := getBootAppearanceByID(provider, appearanceID); resolveErr != nil {\n\t\t\terr = ErrBootAppearanceNotFound\n\t\t\treturn\n\t\t}\n\t\tret.Provider, ret.Appearance = provider, appearanceID","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/boot_appearance.go#L196-L232","documentation":"SetBootAppearance persists the boot (splash) appearance selection, but in read-only mode the workspace configuration must not change. When util.ReadOnly is true the call is rejected with 'read-only mode' and the current default selection is returned unchanged.","triggerScenarios":"Calling SetBootAppearance (or its HTTP API) while the kernel runs in read-only mode — e.g. read-only startup flag, workspace on read-only media, or read-only enforced by the environment.","commonSituations":"Accessing a SiYuan instance started with read-only enabled (demo/preview deployments, shared workspaces); automated tests or scripts trying to change settings on such an instance.","solutions":["Restart the kernel without read-only mode before changing boot appearance","Make the change in a writable instance/workspace instead","Have the UI hide/disable appearance settings when read-only is active"],"exampleFix":"// before\n_, err := model.SetBootAppearance(provider, id) // may fail in read-only\n// after\nif util.ReadOnly { return errors.New(\"cannot change boot appearance in read-only mode\") }\n_, err := model.SetBootAppearance(provider, id)","handlingStrategy":"try-catch","validationCode":"if util.ReadOnly { return errors.New(\"workspace is read-only\") }","typeGuard":null,"tryCatchPattern":"sel, err := model.SetBootAppearance(p, id)\nif err != nil && strings.Contains(err.Error(), \"read-only\") {\n  // disable UI and inform user the workspace is read-only\n}","preventionTips":["Check util.ReadOnly before offering write-config UI","Don't attempt config writes on demo/read-only deployments","Surface read-only state in the settings UI"],"tags":["go","kernel","read-only","boot-appearance"],"backgroundTag":"permission-denied","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"}