{"record":{"id":"6b57ac5f762aa2fc","repo":"siyuan-note/siyuan","slug":"wrong-layout-type","errorCode":null,"errorMessage":"wrong layout type","messagePattern":"wrong layout type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1299,"sourceCode":"\t\t\tlogging.LogErrorf(\"create attribute view dir failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                 // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\" // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)\n","sourceCodeStart":1281,"sourceCodeEnd":1313,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/av.go#L1281-L1313","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only switch to one of the supported layouts: table (0), gallery, or kanban — check the current LayoutType constants.","Guard layout-specific operations with a check on view.LayoutType before submitting.","If the client is older, update it so its layout enum matches the server's av.LayoutType values."],"exampleFix":"// before\nchangeAttrViewLayout(av, view, av.LayoutType(99))   // -> wrong layout type\n\n// after: use a supported layout constant\nswitch newLayout {\ncase av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:\n    changeAttrViewLayout(av, view, newLayout)\ndefault:\n    return av.ErrWrongLayoutType\n}","handlingStrategy":"validation","validationCode":"// Only allow supported layouts\nswitch newLayout {\ncase av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:\ndefault:\n    return av.ErrWrongLayoutType\n}\n// And guard layout-specific ops by current layout\nif op.IsTableOnly() && view.LayoutType != av.LayoutTypeTable {\n    return av.ErrWrongLayoutType\n}","typeGuard":"// TypeScript guard\nconst SUPPORTED_LAYOUTS = new Set([0 /*table*/, 1 /*gallery*/, 2 /*kanban*/])\nfunction isSupportedLayout(t: number): boolean {\n  return SUPPORTED_LAYOUTS.has(t)\n}","tryCatchPattern":null,"preventionTips":["Check view.LayoutType before issuing layout-specific operations.","Keep the client's layout enum in sync with the server's av.LayoutType constants.","Validate the target layout is in {table, gallery, kanban} before switching."],"tags":["attribute-view","layout","validation","api"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}