siyuan-note/siyuan · error

ErrWrongLayoutType

ErrWrongLayoutType

Error message

wrong layout type

What it means

ErrWrongLayoutType is returned when an operation is applied to an attribute view view whose layout type does not support it — e.g. card-layout, column-full-row, or cover-position settings only apply to table/gallery/kanban layouts, and model-level layout switchers reject unknown target layouts.

Solutions

  1. Check view.LayoutType is one of av.LayoutTypeTable/Gallery/Kanban before applying layout-specific settings
  2. Validate the layout parameter client-side against the current kernel's supported layout list
  3. Update kernel/frontend together when a new layout type is introduced

Example fix

// before
err = setAttrViewCardBench(avID, viewID, layout) // any layout accepted
// after
switch view.LayoutType {
case av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:
    // ok
default:
    return av.ErrWrongLayoutType
}
Defensive patterns

Strategy: validation

Validate before calling

switch view.LayoutType {
case av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:
    // proceed
default:
    return errors.New("layout does not support card settings")
}

Type guard

func supportsCardLayout(lt av.LayoutType) bool {
    return lt == av.LayoutTypeTable || lt == av.LayoutTypeGallery || lt == av.LayoutTypeKanban
}

Prevention

When it happens

Trigger: setAttrViewCardLayout / setAttrViewColFullRow / setAttrViewCardCoverPosition called on a view whose LayoutType is not table/gallery/kanban; changeAttrViewLayout or CreateAttributeViewDatabase receiving a layout string outside the supported set.

Common situations: Frontend/plugin sending a layout id from an older or newer spec (e.g. a new layout type the current kernel doesn't know); a request payload where the layout field is a typo or empty; switching settings on a board after it was converted to another layout.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at kernel/av/av.go:1389

			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")
	ErrRichTextSpecMismatch   = errors.New("attribute view rich text requires storage spec 9")
	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,逗号分隔
	NodeAttrContextFilter  = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
	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 9f775e8a12)