{"record":{"id":"1783409bfd43d2f6","repo":"siyuan-note/siyuan","slug":"invalid-width-for-attribute-view-column-s","errorCode":null,"errorMessage":"invalid width for attribute view column [%s]","messagePattern":"invalid width for attribute view column \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":6824,"sourceCode":"\nfunc (tx *Transaction) doSetAttrViewColumnsWidth(operation *Operation) (ret *TxErr) {\n\terr := setAttributeViewColsWidth(operation)\n\tif err != nil {\n\t\treturn &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}\n\t}\n\treturn\n}\n\nfunc setAttributeViewColsWidth(operation *Operation) (err error) {\n\twidthData, ok := operation.Data.(map[string]any)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid attribute view column widths\")\n\t}\n\twidths := map[string]string{}\n\tfor id, value := range widthData {\n\t\twidth, valueOK := value.(string)\n\t\tif !valueOK {\n\t\t\treturn fmt.Errorf(\"invalid width for attribute view column [%s]\", id)\n\t\t}\n\t\twidths[id] = width\n\t}\n\n\tattrView, err := av.ParseAttributeView(operation.AvID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tview, err := getAttrViewViewByBlockID(attrView, operation.BlockID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif av.LayoutTypeTable != view.LayoutType {\n\t\treturn nil\n\t}\n\tfor _, column := range view.Table.Columns {\n\t\tif width, found := widths[column.ID]; found {\n\t\t\tcolumn.Width = av.FilterWidthValue(width)","sourceCodeStart":6806,"sourceCodeEnd":6842,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L6806-L6842","documentation":"While building the width map inside setAttributeViewColsWidth, each value in the Data map must be a string (the CSS width). If any value is a number, boolean, or nested object, the assertion value.(string) fails and the error names the offending column ID.","triggerScenarios":"POSTing a setAttrViewColWidth operation where one entry is {\"colId\": 200} (number) instead of {\"colId\": \"200px\"}.","commonSituations":"Scripts computing widths numerically and forgetting to stringify; plugins copying widths from DOM px values as numbers; schema drift between client versions.","solutions":["Convert every width value to a string, including units (e.g. \"200px\")","Locate the column named in the [%s] interpolation and fix that entry","Validate the width object client-side before queuing the transaction"],"exampleFix":"// before\n{\"20240101xxxx\": 200}\n// after\n{\"20240101xxxx\": \"200px\"}","handlingStrategy":"validation","validationCode":"for (const [id, w] of Object.entries(widths)) {\n  if (typeof w !== \"string\") throw new Error(`width for column ${id} must be a string, got ${typeof w}`);\n}","typeGuard":"const isWidthEntry = (e: [string, unknown]): e is [string, string] => typeof e[1] === \"string\";","tryCatchPattern":"try { await setAttrViewColWidth(op); } catch (e) { const m = String(e).match(/invalid width for attribute view column \\[(.+)\\]/); if (m) { widths[m[1]] = String(widths[m[1]]) + \"px\"; } else throw e; }","preventionTips":["Stringify numeric widths at the point of computation","Keep widths as CSS strings throughout the plugin","Test API payloads against a real kernel before release"],"tags":["attribute-view","api","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}