siyuan-note/siyuan · error

invalid tabs position

Error message

invalid tabs position [%s]

What it means

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.

Solutions

  1. Use only "top" or "left" as the tabs-position value
  2. Trim/case-check the value before sending (attribute names are lowercased; value must match exactly)
  3. Update the plugin/script to clamp unknown values to a valid default
  4. If the value came from stored settings, reset the tabs position in the UI

Example fix

// before
setNodeAttrs(tabsID, {"custom-tabs-position": "bottom"})
// after
const pos = ["top","left"].includes(want) ? want : "top";
setNodeAttrs(tabsID, {"custom-tabs-position": pos})
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ["top", "left"];
if (!VALID.includes(position.trim())) throw new Error(`invalid tabs position ${position}`);

Type guard

function isValidTabsPosition(v) {
  return v === "top" || v === "left";
}

Prevention

When it happens

Trigger: 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.

Common situations: Plugins or scripts hard-coding an unsupported position value; UI state saved from an older/modified client; manual .sy JSON edits with invalid values.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/2a0adfb5712cd9c9. Report an issue: GitHub.

Appendix: source

Thrown at kernel/treenode/tabs.go:57

}

// ValidateTabsAttrs 在修改属性前校验页签属性,避免部分属性已写入后才发现错误。
func ValidateTabsAttrs(node *ast.Node, attrs map[string]string) error {
	for name, value := range attrs {
		name = strings.ToLower(name)
		if TabsActiveIDAttr != name && TabsPositionAttr != name {
			continue
		}
		if nil == node || ast.NodeTabs != node.Type {
			return fmt.Errorf("attribute [%s] is only supported on tab containers", name)
		}
		value = strings.TrimSpace(util.RemoveInvalidRetainCtrl(value))
		if "" == value {
			continue
		}
		if TabsPositionAttr == name {
			if "top" != value && "left" != value {
				return fmt.Errorf("invalid tabs position [%s]", value)
			}
			continue
		}
		found := false
		for item := node.FirstChild; nil != item; item = item.Next {
			if ast.NodeTabItem == item.Type && item.ID == value {
				found = true
				break
			}
		}
		if !found {
			return fmt.Errorf("active tab [%s] is not a direct child of [%s]", value, node.ID)
		}
	}
	return nil
}

// NormalizeTabs 修复空页和无效选中项,保留所有已有内容及块标识。

View on GitHub (pinned to 9f775e8a12)