{"record":{"id":"984c33a440862327","repo":"larksuite/cli","slug":"sheet-q-created-but-resolving-its-id-failed-w","errorCode":null,"errorMessage":"sheet %q created but resolving its id failed: %w","messagePattern":"sheet %q created but resolving its id failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_table_io.go","lineNumber":1132,"sourceCode":"// across tool-response variations.\nfunc createSheet(ctx context.Context, runtime *common.RuntimeContext, token, name string, rows, cols int) (string, error) {\n\tinput := map[string]interface{}{\n\t\t\"excel_id\":   token,\n\t\t\"operation\":  \"create\",\n\t\t\"sheet_name\": name,\n\t}\n\tif rows > 0 {\n\t\tinput[\"rows\"] = rows\n\t}\n\tif cols > 0 {\n\t\tinput[\"columns\"] = cols\n\t}\n\tif _, err := callTool(ctx, runtime, token, ToolKindWrite, \"modify_workbook_structure\", input); err != nil {\n\t\treturn \"\", err\n\t}\n\tid, _, err := lookupSheetIndex(ctx, runtime, token, \"\", name)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"sheet %q created but resolving its id failed: %w\", name, err) //nolint:forbidigo // intermediate error; surfaced as a partial_success message string via tablePutPartial, not a typed final error\n\t}\n\treturn id, nil\n}\n\n// sheetCreateDims sizes a to-be-created sheet to the spec's write range so the\n// grid matches the payload from the start (the backend would also auto-expand\n// on write; see createSheet). It accounts for the start_cell offset, the\n// optional header row, and any --styles extent (so a cell_styles / merge /\n// resize op past the data still fits the grid). The backend's 20×200 defaults\n// are kept as floors (ordinary small tables are created exactly as before) and\n// its hard limits (200 cols, 50000 rows) as ceilings.\nfunc sheetCreateDims(s *tableSheetSpec, styles *workbookCreateStylePayload) (rows, cols int) {\n\t_, col0, row0, _ := sheetAnchor(s)\n\tcols = col0 + len(s.Columns)\n\trows = row0 + len(s.Rows)\n\t// Match writeSheetData's header decision exactly. headerOn() is false for\n\t// append mode by default, but writeSheetData *forces* a header when append\n\t// hits an empty sheet with no explicit Header choice (so column names","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_table_io.go#L1114-L1150","documentation":"createSheet issues the modify_workbook_structure create call, then looks up the new sheet's ID by name via lookupSheetIndex. This error means the sheet was created but the follow-up ID lookup failed, leaving the write unable to proceed. It is surfaced as a partial_success message string via tablePutPartial.","triggerScenarios":"lark sheet table put creating a new sheet where the create succeeds but the immediate sheet-list/lookup fails — transient API error, rate limit, or the listing call rejects due to permissions.","commonSituations":"Rate limiting right after a structure mutation; flaky network between the two calls; very large workbooks where listing times out.","solutions":["Re-run the put; the second attempt will likely find the already-created sheet by name instead of creating a duplicate.","Check for a duplicate sheet left by the failed run and remove it if the retry hits a name conflict.","Back off and retry if the cause is rate limiting after the structure mutation.","Verify listing permissions on the workbook if lookups consistently fail."],"exampleFix":"// before: retry immediately (may duplicate or conflict)\nlark sheet table put --token T --sheet Metrics ...\n// after: list sheets first, then retry only if missing\nlark sheet table get --token T --sheet Metrics || lark sheet table put --token T --sheet Metrics ...","handlingStrategy":"retry","validationCode":"// after any create, confirm the sheet resolves before writing:\nout, err := runCLI(\"lark\", \"sheet\", \"table\", \"get\", \"--token\", token, \"--sheet\", name)\nif err != nil { /* sheet missing or unreadable — clean up or retry */ }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"created but resolving its id failed\") {\n\t// list sheets; if it exists, retry the put (it will match by name)\n}","preventionTips":["Back off after structure mutations before follow-up calls.","Check for duplicate sheets left by failed runs.","Keep workbooks modest in sheet count to avoid slow listings."],"tags":["sheets","sheet-creation","lookup"],"backgroundTag":"sheet-id-lookup-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"}