{"record":{"id":"4bb773fdbf394afd","repo":"siyuan-note/siyuan","slug":"errinvalidcolumnalign","errorCode":"ErrInvalidColumnAlign","errorMessage":"invalid column align","messagePattern":"invalid column align","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1346,"sourceCode":"\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":1328,"sourceCodeEnd":1361,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1328-L1361","documentation":"ErrInvalidColumnAlign is returned when setting a table column's alignment with a value that either doesn't convert to av.TableColumnAlign or fails TableColumnAlign.IsValid(). Alignment accepts only the defined enum values (e.g. left/center/right); anything else is rejected before mutating the view.","triggerScenarios":"Calling the set-column-align operation with alignValue outside the valid TableColumnAlign set (0 -> not ok, or a number with no valid alignment mapping) in kernel/model/attribute_view.go:6792.","commonSituations":"A plugin or script passing raw user input as the alignment number; frontend sending undefined/NaN coerced to 0; copied integration code using an alignment constant from a different library; off-by-one on the enum indices.","solutions":["Use the av.TableColumnAlign enum values (and IsValid()) to validate before sending the align operation","Default to the existing alignment or 'left' when the requested value is invalid","Clamp/whitelist alignment input on the plugin side (e.g. only 0..2 as documented)","Re-read the column settings from RenderAttributeView to confirm the current valid values"],"exampleFix":"// before\nsetAttrViewColumnAlign(avID, viewID, colID, 9) // ErrInvalidColumnAlign\n// after\nalign := av.TableColumnAlign(requested)\nif !align.IsValid() {\n    align = av.TableColumnAlignLeft\n}\nsetAttrViewColumnAlign(avID, viewID, colID, int(align))","handlingStrategy":"validation","validationCode":"align := av.TableColumnAlign(requestedAlign)\nif !align.IsValid() {\n    return fmt.Errorf(\"invalid column align %d\", requestedAlign)\n}","typeGuard":"func validAlign(n int) bool { return av.TableColumnAlign(n).IsValid() }","tryCatchPattern":"err := setAttrViewColumnAlign(avID, viewID, colID, requested)\nif errors.Is(err, av.ErrInvalidColumnAlign) {\n    err = setAttrViewColumnAlign(avID, viewID, colID, int(av.TableColumnAlignLeft))\n}","preventionTips":["Sanitize numeric alignment input before sending it to the kernel","Use the documented TableColumnAlign enum values only","Coerce undefined/NaN alignment from the UI to a default before invoking the operation"],"tags":["go","attribute-view","table","invalid-enum"],"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"}