{"record":{"id":"4bdd7fb3e6748081","repo":"larksuite/cli","slug":"creating-sheet-q-failed-w","errorCode":null,"errorMessage":"creating sheet %q failed: %w","messagePattern":"creating sheet %q failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_table_io.go","lineNumber":1062,"sourceCode":"\n\twritten := make([]interface{}, 0, len(payload.Sheets))\n\tfor i := range payload.Sheets {\n\t\ts := &payload.Sheets[i]\n\t\tsheetID, ok := byName[s.Name]\n\t\tif !ok {\n\t\t\t// The missing target will be created EMPTY, so append resolves its\n\t\t\t// base row to the static anchor — validate style anchors (row\n\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 {","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_table_io.go#L1044-L1080","documentation":"When a payload sheet name does not match any existing sheet in the workbook, writeTypedSheets creates it with the exact grid size the payload needs. This error wraps a createSheet failure and is returned with the list of sheets written so far, then surfaced as a partial_success message string via tablePutPartial.","triggerScenarios":"lark sheet table put with a new sheet name where the modify_workbook_structure create call fails: duplicate name race (another sheet just created with that name), invalid sheet title, permission denial, or API error.","commonSituations":"Two concurrent puts creating the same sheet name; sheet titles with characters the API rejects; token without structure-edit rights; rate limiting on workbooks with many sheets.","solutions":["Check partial_success: sheets before the failing one were written; retry the whole put or target only the missing sheet.","Ensure the sheet name doesn't already exist (or reuse it by matching the existing name).","Use a simpler ASCII sheet title without slashes or special characters.","Confirm the token has permission to modify workbook structure."],"exampleFix":"// before: concurrent duplicate creation\nlark sheet table put --token T --sheet Sales --row ... &  lark sheet table put --token T --sheet Sales --row ...\n// after: serialize the puts or put into distinct sheet names","handlingStrategy":"validation","validationCode":"// ensure no concurrent creator and a valid unique name:\nif existingNames[sheetName] { return fmt.Errorf(\"sheet %q already exists\", sheetName) }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"creating sheet\") {\n\t// note sheets already written from partial_success; retry only the missing sheet\n}","preventionTips":["Serialize puts that may create sheets with the same name.","Use simple, unique, ASCII sheet titles.","Verify structure-edit permission on the workbook beforehand."],"tags":["sheets","sheet-creation","partial-success"],"backgroundTag":"sheet-create-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"}