{"record":{"id":"2df889dd044d4d3c","repo":"sipeed/picoclaw","slug":"feishu-image-upload-no-image-key-returned","errorCode":null,"errorMessage":"feishu image upload: no image_key returned","messagePattern":"feishu image upload: no image_key returned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/feishu/feishu_64.go","lineNumber":1156,"sourceCode":"func (c *FeishuChannel) sendImage(ctx context.Context, chatID string, file *os.File) error {\n\t// Upload image to get image_key\n\tuploadReq := larkim.NewCreateImageReqBuilder().\n\t\tBody(larkim.NewCreateImageReqBodyBuilder().\n\t\t\tImageType(\"message\").\n\t\t\tImage(file).\n\t\t\tBuild()).\n\t\tBuild()\n\n\tuploadResp, err := c.client.Im.V1.Image.Create(ctx, uploadReq)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"feishu image upload: %w\", err)\n\t}\n\tif !uploadResp.Success() {\n\t\tc.invalidateTokenOnAuthError(uploadResp.Code)\n\t\treturn fmt.Errorf(\"feishu image upload api error (code=%d msg=%s)\", uploadResp.Code, uploadResp.Msg)\n\t}\n\tif uploadResp.Data == nil || uploadResp.Data.ImageKey == nil {\n\t\treturn fmt.Errorf(\"feishu image upload: no image_key returned\")\n\t}\n\n\timageKey := *uploadResp.Data.ImageKey\n\n\t// Send image message\n\tcontent, _ := json.Marshal(map[string]string{\"image_key\": imageKey})\n\treq := larkim.NewCreateMessageReqBuilder().\n\t\tReceiveIdType(larkim.CreateMessageV1ReceiveIDTypeChatId).\n\t\tBody(larkim.NewCreateMessageReqBodyBuilder().\n\t\t\tReceiveId(chatID).\n\t\t\tMsgType(larkim.MsgTypeImage).\n\t\t\tContent(string(content)).\n\t\t\tBuild()).\n\t\tBuild()\n\n\tresp, err := c.client.Im.V1.Message.Create(ctx, req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"feishu image send: %w\", err)","sourceCodeStart":1138,"sourceCodeEnd":1174,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/feishu/feishu_64.go#L1138-L1174","documentation":"The image upload returned Success()==true but Data or Data.ImageKey is nil — an unexpected payload where the API claims success yet delivers no image_key. This is a protocol deviation (gateway quirk or SDK/response-shape mismatch), not a normal input error; there is nothing in the request to fix.","triggerScenarios":"Im.V1.Image.Create succeeds with an empty data block; occasionally seen under Feishu gateway incidents, or when the vendored lark SDK version deserializes the response shape differently than the live API emits.","commonSituations":"After upgrading the github.com/larksuite/oapi-sdk-go dependency; during transient Feishu service degradation; region-specific API behavior differences.","solutions":["Retry the upload once — the condition is typically transient.","Pin/upgrade the lark oapi SDK to a version tested against the current Feishu response schema.","Log the raw response body once to confirm data.image_key is genuinely absent (rules out SDK parsing).","If reproducible, file it with Feishu open-platform support including the request ID."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isMissingImageKey(err error) bool {\n    return strings.Contains(err.Error(), \"feishu image upload: no image_key returned\")\n}","tryCatchPattern":"if err := ch.SendMedia(ctx, msg); err != nil {\n    if isMissingImageKey(err) {\n        // unexpected empty payload: retry once; if it repeats, suspect SDK/API schema drift\n    }\n}","preventionTips":["Pin the lark oapi SDK version in go.mod","Retry once on empty-payload errors — they are usually gateway-transient","Log raw upload responses during integration to catch schema drift early"],"tags":["feishu","upload","go","lark-sdk","unexpected-response"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}