{"record":{"id":"70fa901e4e1263a9","repo":"siyuan-note/siyuan","slug":"errwronglayouttype","errorCode":"ErrWrongLayoutType","errorMessage":"wrong layout type","messagePattern":"wrong layout type","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1345,"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\tErrRichTextSpecMismatch   = errors.New(\"attribute view rich text requires storage spec 9\")\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\tNodeAttrContextFilter  = \"custom-sy-av-context-filter\" // 用于保存数据库块独有的上下文筛选配置\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":1327,"sourceCodeEnd":1361,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1327-L1361","documentation":"ErrWrongLayoutType is returned by layout-changing operations (changeAttrViewLayout, setAttrViewCardLayout, setAttrViewColFullRow, setAttrViewCardCoverPosition, CreateAttributeViewDatabase) when the supplied layout value is not one of the supported types (table/gallery/kanban) or when a card-layout/cover/col-full operation is applied to a view whose layout doesn't accept that value.","triggerScenarios":"Passing a layout string other than 'table' | 'gallery' | 'kanban' to changeAttrViewLayout or CreateAttributeViewDatabase; calling setAttrViewCardLayout with a card layout value invalid for the kanban view; applying table-specific ops to non-table views.","commonSituations":"A plugin hardcoding a layout name (e.g. 'list' or a misspelling); older plugin code using a layout value removed from the allowed set; front-end sending an unvalidated layout from user input.","solutions":["Restrict layout values to the av.LayoutTypeTable / av.LayoutTypeGallery / av.LayoutTypeKanban constants","Validate the requested layout against the current view type before calling card/cover/col-full setters","Read the layout options from the API/model layer instead of inventing strings","Handle the error and fall back to the view's existing layout"],"exampleFix":"// before\nchangeAttrViewLayout(avID, viewID, \"list\") // ErrWrongLayoutType\n// after\nlayout := \"list\"\nswitch layout {\ncase \"table\", \"gallery\", \"kanban\":\n    changeAttrViewLayout(avID, viewID, layout)\ndefault:\n    layout = \"table\" // safe fallback\n    changeAttrViewLayout(avID, viewID, layout)\n}","handlingStrategy":"validation","validationCode":"switch layout {\ncase \"table\", \"gallery\", \"kanban\":\ndefault:\n    return fmt.Errorf(\"unsupported layout %q\", layout)\n}","typeGuard":"func isSupportedLayout(l string) bool {\n    return l == \"table\" || l == \"gallery\" || l == \"kanban\"\n}","tryCatchPattern":"err := changeAttrViewLayout(avID, viewID, layout)\nif errors.Is(err, av.ErrWrongLayoutType) {\n    log.Warnf(\"layout %q rejected, keeping current\", layout)\n    return nil\n}","preventionTips":["Only pass av.LayoutTypeTable / Gallery / Kanban constants, never free-form strings","Match card-layout/cover/col-full operations to the view's actual layout type first","Read allowed layouts from the API layer rather than duplicating them in plugin code"],"tags":["go","attribute-view","layout","invalid-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}