siyuan-note/siyuan · error

wrong layout type

Error message

wrong layout type

What it means

Sentinel ErrWrongLayoutType. Returned when an operation targets an unsupported or mismatched layout: changeAttrViewLayout rejects layouts outside {table, gallery, kanban} (model/attribute_view.go:1358), and several operations reject applying a layout-specific action to a view whose layout does not support it (lines 1752, 1800, 1940, 4952).

Source

Thrown at kernel/av/av.go:1299

			logging.LogErrorf("create attribute view dir failed: %s", err)
			return
		}
	}
	return
}

func GetAttributeViewI18n(key string) string {
	return util.AttrViewLangs[util.Lang][key].(string)
}

var (
	ErrAttributeViewNotFound  = errors.New("attribute view not found")
	ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
	ErrInvalidBoxID           = errors.New("invalid box id")
	ErrViewNotFound           = errors.New("view not found")
	ErrKeyNotFound            = errors.New("key not found")
	ErrItemNotFound           = errors.New("item not found")
	ErrWrongLayoutType        = errors.New("wrong layout type")
	ErrInvalidColumnAlign     = errors.New("invalid column align")
	ErrSpecTooNew             = errors.New("attribute view spec is too new")
	ErrFilterTooDeep          = errors.New("filter nesting depth exceeds the maximum allowed")
)

const (
	NodeAttrNameAvs        = "custom-avs"                 // 用于标记块所属的属性视图,逗号分隔 av id
	NodeAttrView           = "custom-sy-av-view"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
	NodeAttrVisibleViewIDs = "custom-sy-av-visible-views" // 用于标记数据库块显示的视图 ID,逗号分隔
	NodeAttrViewStaticText = "custom-sy-av-s-text"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049

	NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Only switch to one of the supported layouts: table (0), gallery, or kanban — check the current LayoutType constants.
  2. Guard layout-specific operations with a check on view.LayoutType before submitting.
  3. If the client is older, update it so its layout enum matches the server's av.LayoutType values.

Example fix

// before
changeAttrViewLayout(av, view, av.LayoutType(99))   // -> wrong layout type

// after: use a supported layout constant
switch newLayout {
case av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:
    changeAttrViewLayout(av, view, newLayout)
default:
    return av.ErrWrongLayoutType
}
Defensive patterns

Strategy: validation

Validate before calling

// Only allow supported layouts
switch newLayout {
case av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:
default:
    return av.ErrWrongLayoutType
}
// And guard layout-specific ops by current layout
if op.IsTableOnly() && view.LayoutType != av.LayoutTypeTable {
    return av.ErrWrongLayoutType
}

Type guard

// TypeScript guard
const SUPPORTED_LAYOUTS = new Set([0 /*table*/, 1 /*gallery*/, 2 /*kanban*/])
function isSupportedLayout(t: number): boolean {
  return SUPPORTED_LAYOUTS.has(t)
}

Prevention

When it happens

Trigger: Calling setview to switch a view to an unsupported layout value; or calling a table-only operation (e.g. column align, column freeze) on a kanban/gallery view; or a gallery-only option on a table view.

Common situations: Client constructed a layout enum value not in the supported set (e.g. an old client sending a removed layout); applying a table column op without first checking the view is a table; plugin assuming a specific layout.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/6b57ac5f762aa2fc. Report an issue: GitHub.