{"record":{"id":"a580e0ef6bfb5705","repo":"chenhg5/cc-connect","slug":"s-send-preview-no-message-id-returned","errorCode":null,"errorMessage":"%s: send preview: no message ID returned","messagePattern":"(.+?): send preview: no message ID returned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5149,"sourceCode":"\t\t\t\tresp, err = client.Im.Message.Create(ctx, req, options...)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"%s: send preview: %w\", p.tag(), err)\n\t\t\t\t}\n\t\t\t\tif !resp.Success() {\n\t\t\t\t\treturn fmt.Errorf(\"%s: send preview code=%d msg=%s\", p.tag(), resp.Code, resp.Msg)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif resp.Data != nil && resp.Data.MessageId != nil {\n\t\t\tmsgID = *resp.Data.MessageId\n\t\t}\n\t}\n\n\tif msgID == \"\" {\n\t\treturn nil, fmt.Errorf(\"%s: send preview: no message ID returned\", p.tag())\n\t}\n\n\treturn &feishuPreviewHandle{messageID: msgID, chatID: chatID, cardID: cardID}, nil\n}\n\n// createCardEntity calls the cardkit-v1 Create Card Entity API\n// (POST /open-apis/cardkit/v1/cards) and returns the card_id.\n//\n// The card_id is required to drive the streaming text update path\n// (PUT /open-apis/cardkit/v1/cards/{card_id}/elements/{element_id}/content).\n// If this call fails the caller should fall back to inline card JSON via the\n// regular Im.Message.Create path; the rich card will still render but without\n// native typewriter streaming.\nfunc (p *Platform) createCardEntity(ctx context.Context, cardJSON string) (string, error) {\n\tbody := map[string]any{\n\t\t\"type\": \"card_json\",\n\t\t\"data\": cardJSON,\n\t}","sourceCodeStart":5131,"sourceCodeEnd":5167,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5131-L5167","documentation":"Thrown by the Feishu platform's send-preview path after a successful (resp.Success()) Reply or Create message call when the response contains no message_id. The SDK can return success with a nil Data or nil MessageId pointer; since streaming/patch updates key off the message ID, the code treats its absence as a hard failure instead of returning a handle with an empty ID.","triggerScenarios":"client.Im.Message.Reply or client.Im.Message.Create returned resp.Success()==true but resp.Data==nil or resp.Data.MessageId==nil; e.g. Lark IM API returning 200 with an empty/oddly-shaped body, or an SDK version whose response struct no longer populates MessageId for interactive messages.","commonSituations":"Bot lacks im:message send scope on the target chat in a way that degrades the response; proxy/gateway stripping the body; Feishu API behavior change or larksuite SDK version mismatch; sending to a chat where the interactive card is accepted but the ID is not echoed back.","solutions":["Check that resp.Data and resp.Data.MessageId are being populated — upgrade github.com/larksuite/oapi-sdk-go to the latest version so CreateMessageResp/ReplyMessageResp shapes match the current API","Log resp.RawBody on this path to see what Feishu actually returned and confirm whether the API call itself succeeded","Verify the bot has im:message:send_as_bot (or im:message) permission and is a member of the target chat","If this recurs after a Feishu API change, fall back to the inline-card-JSON send path instead of failing the preview"],"exampleFix":"// before\nif msgID == \"\" {\n\treturn nil, fmt.Errorf(\"%s: send preview: no message ID returned\", p.tag())\n}\n// after\nif msgID == \"\" {\n\tslog.Warn(p.tag()+\": send preview: no message ID in response, falling back\", \"raw\", string(resp.RawBody))\n\treturn nil, fmt.Errorf(\"%s: send preview: no message ID returned\", p.tag())\n}","handlingStrategy":"type-guard","validationCode":"if resp == nil || resp.Data == nil || resp.Data.MessageId == nil || *resp.Data.MessageId == \"\" {\n\t// treat as preview failure and fall back to non-streaming send\n}","typeGuard":"func messageIDFromResp(resp *larkim.CreateMessageResp) string {\n\tif resp == nil || resp.Data == nil || resp.Data.MessageId == nil {\n\t\treturn \"\"\n\t}\n\treturn *resp.Data.MessageId\n}","tryCatchPattern":"if err != nil {\n\tvar noID *NoMessageIDError\n\tif errors.As(err, &noID) {\n\t\t// fall back to inline-card-JSON send without streaming\n\t}\n}","preventionTips":["Always check resp.Data and resp.Data.MessageId for nil before dereferencing","Pin and regularly upgrade the larksuite oapi-sdk-go version","Keep the inline-card-JSON fallback wired so a missing ID degrades gracefully","Log RawBody on anomalous responses to catch Feishu API drift early"],"tags":["feishu","lark","api-response","streaming-card"],"backgroundTag":"unexpected-api-response-shape","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"}