{"record":{"id":"070ac8346e925551","repo":"larksuite/cli","slug":"writing-sheet-q-failed-w","errorCode":null,"errorMessage":"writing sheet %q failed: %w","messagePattern":"writing sheet %q failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_table_io.go","lineNumber":1070,"sourceCode":"\t\t\t// included) BEFORE the create. Validate could not run this check\n\t\t\t// for append (an existing sheet's base row is dynamic), and\n\t\t\t// skipping it here would strand a freshly created empty sheet\n\t\t\t// behind a \"no sheets were written\" failure.\n\t\t\tif err := checkSheetStyleAnchors(s, styles.styleFor(i), true); err != nil {\n\t\t\t\treturn written, err\n\t\t\t}\n\t\t\trows, cols := sheetCreateDims(s, styles.styleFor(i))\n\t\t\tsheetID, err = createSheet(ctx, runtime, token, s.Name, rows, cols)\n\t\t\tif err != nil {\n\t\t\t\treturn written, fmt.Errorf(\"creating sheet %q failed: %w\", s.Name, err) //nolint:forbidigo // intermediate error; surfaced as a partial_success message string via tablePutPartial, not a typed final error\n\t\t\t}\n\t\t\tbyName[s.Name] = sheetID\n\t\t\t// A freshly created sheet's grid is exactly what we just asked for.\n\t\t\tdimsByName[s.Name] = gridDims{rows: rows, cols: cols}\n\t\t}\n\t\tsummary, err := writeSheetData(ctx, runtime, token, sheetID, s, styles.styleFor(i), dimsByName[s.Name])\n\t\tif err != nil {\n\t\t\treturn written, fmt.Errorf(\"writing sheet %q failed: %w\", s.Name, err) //nolint:forbidigo // intermediate error; surfaced as a partial_success message string via tablePutPartial, not a typed final error\n\t\t}\n\t\twritten = append(written, summary)\n\t}\n\treturn written, nil\n}\n\n// renameSheet renames a sub-sheet in place via modify_workbook_structure. Used\n// to adopt a freshly created workbook's default sheet as the first typed sheet\n// (see writeTypedSheets); mirrors +sheet-rename's tool input.\nfunc renameSheet(ctx context.Context, runtime *common.RuntimeContext, token, sheetID, newName string) error {\n\t_, err := callTool(ctx, runtime, token, ToolKindWrite, \"modify_workbook_structure\", map[string]interface{}{\n\t\t\"excel_id\":  token,\n\t\t\"operation\": \"rename\",\n\t\t\"sheet_id\":  sheetID,\n\t\t\"new_name\":  newName,\n\t})\n\treturn err\n}","sourceCodeStart":1052,"sourceCodeEnd":1088,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_table_io.go#L1052-L1088","documentation":"After a payload sheet is matched or created, writeTypedSheets calls writeSheetData to write its rows. This error wraps any failure inside that write (append-anchor resolution, batch writes, or style application), tagged with the sheet name. It is returned with sheets written so far and surfaced as a partial_success message string via tablePutPartial.","triggerScenarios":"lark sheet table put where the per-sheet write fails for any reason — lastDataRow resolution failure, set_cell_range batch rejection (collision/allow_overwrite, too-small grid), or visual style application failure.","commonSituations":"Multi-sheet payloads where one sheet's data doesn't fit its grid; overwrite collisions; transient API failures partway through a large multi-sheet write.","solutions":["Read the partial_success message: it names the failing sheet; earlier sheets were written successfully.","Re-run the put for just the failing sheet after fixing the underlying cause (mode, grid size, permissions).","If the write collided with existing data, switch to overwrite mode or clear the target range first.","Retry on transient/rate-limit errors with backoff."],"exampleFix":"// before: one sheet too large for created grid\n{\"sheets\": [{\"name\": \"A\", \"rows\": 1000-row-array}]}\n// after: write in chunks per sheet, or specify explicit grid size so creation matches the payload","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"writing sheet\") {\n\t// extract sheet name and underlying cause; fix cause, re-put only that sheet\n}","preventionTips":["Pre-validate each sheet's data against the intended grid size.","Use overwrite mode when replacing existing content.","Handle partial_success results: sheets before the failure are committed."],"tags":["sheets","write-failure","partial-success"],"backgroundTag":"sheet-write-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"}