{"record":{"id":"2a0adfb5712cd9c9","repo":"siyuan-note/siyuan","slug":"invalid-tabs-position-s","errorCode":null,"errorMessage":"invalid tabs position [%s]","messagePattern":"invalid tabs position \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/treenode/tabs.go","lineNumber":57,"sourceCode":"}\n\n// ValidateTabsAttrs 在修改属性前校验页签属性，避免部分属性已写入后才发现错误。\nfunc ValidateTabsAttrs(node *ast.Node, attrs map[string]string) error {\n\tfor name, value := range attrs {\n\t\tname = strings.ToLower(name)\n\t\tif TabsActiveIDAttr != name && TabsPositionAttr != name {\n\t\t\tcontinue\n\t\t}\n\t\tif nil == node || ast.NodeTabs != node.Type {\n\t\t\treturn fmt.Errorf(\"attribute [%s] is only supported on tab containers\", name)\n\t\t}\n\t\tvalue = strings.TrimSpace(util.RemoveInvalidRetainCtrl(value))\n\t\tif \"\" == value {\n\t\t\tcontinue\n\t\t}\n\t\tif TabsPositionAttr == name {\n\t\t\tif \"top\" != value && \"left\" != value {\n\t\t\t\treturn fmt.Errorf(\"invalid tabs position [%s]\", value)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tfound := false\n\t\tfor item := node.FirstChild; nil != item; item = item.Next {\n\t\t\tif ast.NodeTabItem == item.Type && item.ID == value {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"active tab [%s] is not a direct child of [%s]\", value, node.ID)\n\t\t}\n\t}\n\treturn nil\n}\n\n// NormalizeTabs 修复空页和无效选中项，保留所有已有内容及块标识。","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/treenode/tabs.go#L39-L75","documentation":"Validation in ValidateTabsAttrs: a tabs-position attribute value is neither \"top\" nor \"left\" after trimming, so the write would produce an invalid tab-container layout and is rejected before any attribute is persisted.","triggerScenarios":"Setting custom-tabs-position to any string other than \"top\"/\"left\" (after trimming) through the attribute-setting API on a tabs container, e.g. \"right\", \"bottom\", or a typo.","commonSituations":"Plugins or scripts hard-coding an unsupported position value; UI state saved from an older/modified client; manual .sy JSON edits with invalid values.","solutions":["Use only \"top\" or \"left\" as the tabs-position value","Trim/case-check the value before sending (attribute names are lowercased; value must match exactly)","Update the plugin/script to clamp unknown values to a valid default","If the value came from stored settings, reset the tabs position in the UI"],"exampleFix":"// before\nsetNodeAttrs(tabsID, {\"custom-tabs-position\": \"bottom\"})\n// after\nconst pos = [\"top\",\"left\"].includes(want) ? want : \"top\";\nsetNodeAttrs(tabsID, {\"custom-tabs-position\": pos})","handlingStrategy":"validation","validationCode":"const VALID = [\"top\", \"left\"];\nif (!VALID.includes(position.trim())) throw new Error(`invalid tabs position ${position}`);","typeGuard":"function isValidTabsPosition(v) {\n  return v === \"top\" || v === \"left\";\n}","tryCatchPattern":null,"preventionTips":["Whitelist position values in plugins before writing the attribute","Trim values exactly as the kernel does (space + control chars)","Clamp persisted settings to known values when loading"],"tags":["validation","tabs","enum"],"backgroundTag":"invalid-enum-value","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"}