{"record":{"id":"2ac1040fcdf43378","repo":"larksuite/cli","slug":"applying-visual-styles-w","errorCode":null,"errorMessage":"applying visual styles: %w","messagePattern":"applying visual styles: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_table_io.go","lineNumber":935,"sourceCode":"\t\t\tend = len(matrix)\n\t\t}\n\t\tbatchRange := fmt.Sprintf(\"%s%d:%s%d\", startCol, baseRow+start+1, endCol, baseRow+end)\n\t\tinput := map[string]interface{}{\n\t\t\t\"excel_id\": token,\n\t\t\t\"sheet_id\": sheetID,\n\t\t\t\"range\":    batchRange,\n\t\t\t\"cells\":    matrix[start:end],\n\t\t}\n\t\tif !allowOverwrite {\n\t\t\tinput[\"allow_overwrite\"] = false\n\t\t}\n\t\tif _, err := callTool(ctx, runtime, token, ToolKindWrite, \"set_cell_range\", input); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"writing rows %d-%d: %w\", start+1, end, err) //nolint:forbidigo // intermediate error; surfaced as a partial_success message string via tablePutPartial, not a typed final error\n\t\t}\n\t\twrites++\n\t}\n\tif err := applyWorkbookCreateVisualOps(ctx, runtime, token, sheetID, styles); err != nil {\n\t\treturn nil, fmt.Errorf(\"applying visual styles: %w\", err) //nolint:forbidigo // intermediate error; surfaced as a partial_success message string via tablePutPartial, not a typed final error\n\t}\n\treturn map[string]interface{}{\n\t\t\"name\":      s.Name,\n\t\t\"sheet_id\":  sheetID,\n\t\t\"range\":     fmt.Sprintf(\"%s%d:%s%d\", startCol, baseRow+1, endCol, baseRow+len(matrix)),\n\t\t\"data_rows\": len(s.Rows),\n\t\t\"columns\":   writeCols,\n\t\t\"writes\":    writes,\n\t\t\"mode\":      writeModeName(s),\n\t}, nil\n}\n\n// writeModeName normalizes the sheet's write mode to a non-empty label for\n// result / dry-run reporting (\"\" defaults to \"overwrite\").\nfunc writeModeName(s *tableSheetSpec) string {\n\tif s.Mode == \"append\" {\n\t\treturn \"append\"\n\t}","sourceCodeStart":917,"sourceCodeEnd":953,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_table_io.go#L917-L953","documentation":"After writing cell data, writeSheetData applies visual styles (fills, formats, merges) via applyWorkbookCreateVisualOps. This error wraps any failure of that styling pass. Data rows may already be written; the error is surfaced as a partial_success message string via tablePutPartial rather than a typed final error.","triggerScenarios":"lark sheet table put with style specs (--styles or payload styles) where a style-apply API call fails: invalid style range, unsupported style op, permission or rate-limit rejection from the Lark styling endpoint.","commonSituations":"Style range strings referencing columns/rows outside the written grid; complex style payloads on sheets with restrictive permissions; transient API errors when applying many style ops in sequence.","solutions":["Retry the put; if data was written, only the styling step needs to succeed on retry.","Validate style ranges fall inside the sheet's written grid dimensions.","Reduce the number of style ops per call to avoid rate limits.","Check the token's permission to modify cell styles on the target sheet."],"exampleFix":"// before: style range outside written grid\n{\"styles\": [{\"range\": \"A1:F999\", \"bg\": \"#EEE\"}]}\n// after: keep style ranges within the written matrix\n{\"styles\": [{\"range\": \"A1:F10\", \"bg\": \"#EEE\"}]}","handlingStrategy":"retry","validationCode":"// check style ranges fit inside the written grid:\nfor _, st := range styles {\n\tif !withinGrid(st.Range, writtenRows, writtenCols) { return fmt.Errorf(\"style range %s out of grid\", st.Range) }\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"applying visual styles\") {\n\t// data likely written; retry the put or apply styles separately\n}","preventionTips":["Keep style ranges within the payload's row/column bounds.","Limit style ops per call to avoid rate limits.","Grant the token style-modification permissions on the sheet."],"tags":["sheets","styles","partial-success"],"backgroundTag":"sheet-style-apply-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}