{"record":{"id":"f1f4d70156db871c","repo":"siyuan-note/siyuan","slug":"attribute-s-is-only-supported-on-tab-containers","errorCode":null,"errorMessage":"attribute [%s] is only supported on tab containers","messagePattern":"attribute \\[(.+?)\\] is only supported on tab containers","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/treenode/tabs.go","lineNumber":49,"sourceCode":"\t\tif nil == ret {\n\t\t\tret = item\n\t\t}\n\t\tif item.ID == activeID {\n\t\t\treturn item\n\t\t}\n\t}\n\treturn\n}\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}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/treenode/tabs.go#L31-L67","documentation":"ValidateTabsAttrs checks custom attributes written to nodes. The attributes tabs-active-id and tabs-position are only meaningful on a tab container (ast.NodeTabs). This error is returned when such an attribute is submitted for a node that is nil or not a tabs container.","triggerScenarios":"Calling the attribute-setting API (setNodeAttrs0 path) with attributes like custom-tabs-position or custom-tabs-active-id on a block that is not a Tabs node; passing a nil node.","commonSituations":"Plugin/script applying tab attributes to a regular block; automation targeting the wrong node ID; UI bug sending tab attrs after the container was converted to another block type.","solutions":["Target the actual Tabs container block ID, not a child or unrelated block","Remove the tabs-* custom attributes from non-tabs blocks","Verify node type before setting attributes (check the block's type via the API)","If a plugin sets these attrs, fix it to validate the node type first"],"exampleFix":"// before\nsetNodeAttrs(blockID, {\"custom-tabs-position\": \"left\"}) // blockID is a paragraph\n// after\nif block.type === \"tabs\" { setNodeAttrs(blockID, {\"custom-tabs-position\": \"left\"}) }","handlingStrategy":"validation","validationCode":"const res = await fetchSyncPost('/api/attr/getBlockAttrs', {id});\nif (res.data.Type !== 'tabs') throw new Error('tabs attrs need a tabs container');","typeGuard":"function isTabsContainer(block) {\n  return block && block.type === \"tabs\";\n}","tryCatchPattern":"try {\n  await setNodeAttrs(id, {\"custom-tabs-position\": \"left\"});\n} catch (e) {\n  if (e.message.includes(\"only supported on tab containers\")) {\n    console.warn(\"target block is not a tabs container\", id);\n  }\n}","preventionTips":["Resolve the Tabs container ID before setting tab attributes","Check block type via API before writing tabs-* attributes","Clean up stale tabs-* attributes from converted blocks"],"tags":["validation","attributes","tabs"],"backgroundTag":"invalid-argument-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"}