{"record":{"id":"cd5392d1042fec9c","repo":"chenhg5/cc-connect","slug":"s-w-cd5392","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5190,"sourceCode":"\t\treturn err\n\t}); err != nil {\n\t\treturn \"\", fmt.Errorf(\"%s: create card entity: %w\", p.tag(), err)\n\t}\n\tif apiResp == nil || apiResp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"%s: create card entity: HTTP status %d\", p.tag(), apiResp.StatusCode)\n\t}\n\tvar resp struct {\n\t\tCode int    `json:\"code\"`\n\t\tMsg  string `json:\"msg\"`\n\t\tData struct {\n\t\t\tCardID string `json:\"card_id\"`\n\t\t} `json:\"data\"`\n\t}\n\tif err := json.Unmarshal(apiResp.RawBody, &resp); err != nil {\n\t\treturn \"\", fmt.Errorf(\"%s: create card entity: parse response: %w\", p.tag(), err)\n\t}\n\tif resp.Code != 0 {\n\t\treturn \"\", fmt.Errorf(\"%s: %w\", p.tag(), classifyFeishuCardAPIError(\"create card entity\", resp.Code, resp.Msg))\n\t}\n\tif resp.Data.CardID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%s: create card entity: empty card_id in response\", p.tag())\n\t}\n\treturn resp.Data.CardID, nil\n}\n\n// StreamRichCardText implements core.RichCardTextStreamer. Pushes the latest\n// fullText to the rich card's main_text element via cardkit-v1 streaming text\n// update API. The Lark client renders the increment between consecutive PUTs\n// with a typewriter animation (controlled by the card's streaming_config).\n//\n// Returns ErrNotSupported when the handle has no cardID (preview was created\n// via the inline-card-JSON fallback path; engine should fall back to full-card\n// Patch).\nfunc (p *Platform) StreamRichCardText(ctx context.Context, previewHandle any, fullText string) error {\n\th, ok := previewHandle.(*feishuPreviewHandle)\n\tif !ok {","sourceCodeStart":5172,"sourceCodeEnd":5208,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5172-L5208","documentation":"The Cardkit Create Card Entity call returned HTTP 200 with parseable JSON, but resp.Code != 0 — a Lark business-level error. The code/Msg are run through classifyFeishuCardAPIError, which maps known codes (rate limit, permission, invalid param, card-not-exist, etc.) to sentinel errors, and the result is wrapped with %w so callers can errors.Is against those sentinels.","triggerScenarios":"Feishu Cardkit API rejects the create request with a non-zero code: invalid card JSON schema (CardParamInvalid), missing permission (403-class codes), rate limiting (e.g. 230020-class codes), or other Cardkit business errors reported inside a 200 HTTP body.","commonSituations":"Card JSON built for an older card schema version; bot app lacking Cardkit scopes; streaming too aggressively and hitting per-app rate limits; malformed generated card during agent streaming.","solutions":["Read the classified inner error (errors.Is against errFeishuCardRateLimited etc.) and the resp.Code/Msg to identify the exact Lark error","Fix the card JSON schema to match the current Cardkit v1 schema","Grant and release Cardkit permissions for the app in the Feishu developer console","Rely on the existing fallback: if card entity creation fails, the engine falls back to inline-card-JSON via Im.Message.Create"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate card JSON before creating the entity\nif json.Valid([]byte(cardJSON)) == false {\n\treturn fmt.Errorf(\"card JSON invalid\")\n}","typeGuard":null,"tryCatchPattern":"cardID, err := p.createCardEntity(ctx, cardJSON)\nif err != nil {\n\tif errors.Is(err, errFeishuCardRateLimited) {\n\t\t// back off and retry later\n\t} else {\n\t\t// fall back to inline-card JSON send\n\t}\n}","preventionTips":["Match card JSON against the current Cardkit v1 schema","Use errors.Is against classifyFeishuCardAPIError sentinels for precise handling","Respect rate limits; pace streaming frames well below 50 QPS","Keep Cardkit scopes granted and released for the app"],"tags":["feishu","cardkit","api-error","rate-limit"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}