{"record":{"id":"6707cf593c1f8c6c","repo":"chenhg5/cc-connect","slug":"s-upload-image-no-image-key-returned","errorCode":null,"errorMessage":"%s: upload image: no image_key returned","messagePattern":"(.+?): upload image: no image_key returned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":3305,"sourceCode":"\t\t\t\t\tImageType(\"message\").\n\t\t\t\t\tImage(bytes.NewReader(data)).\n\t\t\t\t\tBuild()).\n\t\t\t\tBuild()\n\t\t\tvar err error\n\t\t\tuploadResp, err = client.Im.Image.Create(ctx, req, options...)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: upload image: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !uploadResp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: upload image code=%d msg=%s\", p.tag(), uploadResp.Code, uploadResp.Msg)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t}); err != nil {\n\t\treturn \"\", err\n\t}\n\tif uploadResp.Data == nil || uploadResp.Data.ImageKey == nil {\n\t\treturn \"\", fmt.Errorf(\"%s: upload image: no image_key returned\", p.tag())\n\t}\n\n\treturn *uploadResp.Data.ImageKey, nil\n}\n\nfunc (p *Platform) SendFile(ctx context.Context, rctx any, file core.FileAttachment) error {\n\trc, ok := rctx.(replyContext)\n\tif !ok {\n\t\treturn fmt.Errorf(\"%s: SendFile: invalid reply context type %T\", p.tag(), rctx)\n\t}\n\n\tfileName := file.FileName\n\tif fileName == \"\" {\n\t\tfileName = \"attachment\"\n\t}\n\tfileType := detectFeishuFileType(file.MimeType, fileName)\n\tvar uploadResp *larkim.CreateFileResp\n\tif err := p.withTransientRetry(ctx, \"upload file\", func() error {","sourceCodeStart":3287,"sourceCodeEnd":3323,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L3287-L3323","documentation":"The image upload call reported success but the response payload is missing the expected fields: uploadResp.Data is nil or Data.ImageKey is nil. This is an unexpected/empty API response — the library cannot proceed to send the image without the image_key, so it fails explicitly.","triggerScenarios":"uploadResp.Success() was true but Data/ImageKey are nil after the Im.Image.Create call at platform/feishu/feishu.go:3305 — typically an SDK version where the response struct field names changed, or Feishu returning an empty body on a 2xx.","commonSituations":"Outdated or mismatched github.com/larksuite/oapi-sdk version where ImageKey is not populated; Feishu-side incident returning 200 with empty body; proxy mangling the response.","solutions":["Log the full uploadResp (raw body/RequestId) when this occurs and report/compare against the SDK's response struct.","Update the lark/oapi-sdk to the latest version to match current Feishu response shapes.","Retry the upload once — transient empty responses are usually not reproducible.","Add a defensive nil check and a clearer error including RequestId as this code already does."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if uploadResp == nil || uploadResp.Data == nil || uploadResp.Data.ImageKey == nil {\n    return errors.New(\"feishu: image upload returned no image_key\")\n}","typeGuard":"func hasImageKey(r *larkim.CreateImageResp) bool {\n    return r != nil && r.Data != nil && r.Data.ImageKey != nil\n}","tryCatchPattern":"key, err := uploadImage(ctx, data)\nif errors.Is(err, errNoImageKey) {\n    // retry once, then report with RequestId\n}","preventionTips":["Keep the lark/oapi-sdk dependency up to date.","Nil-check Data/ImageKey before dereferencing.","Log full raw response (RequestId) on empty payloads to aid Feishu support tickets."],"tags":["feishu","upload","empty-response","sdk"],"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-14T00:17:10.932Z"}