{"record":{"id":"5ceb032e507fd321","repo":"chenhg5/cc-connect","slug":"s-upload-video-no-file-key-returned","errorCode":null,"errorMessage":"%s: upload video: no file_key returned","messagePattern":"(.+?): upload video: no file_key returned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5578,"sourceCode":"\t\t\t\t\tFileName(fileName).\n\t\t\t\t\tFile(bytes.NewReader(video)).\n\t\t\t\t\tBuild()).\n\t\t\t\tBuild()\n\t\t\tvar err error\n\t\t\tuploadResp, err = client.Im.File.Create(ctx, req, options...)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: upload video: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !uploadResp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: upload video 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.FileKey == nil {\n\t\treturn fmt.Errorf(\"%s: upload video: no file_key returned\", p.tag())\n\t}\n\tfileKey := *uploadResp.Data.FileKey\n\n\tslog.Debug(p.tag()+\": video uploaded\", \"file_key\", fileKey, \"format\", format, \"size\", len(video))\n\n\tmediaMsg := larkim.MessageMedia{FileKey: fileKey}\n\tmediaContent, err := mediaMsg.String()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: build video message: %w\", p.tag(), err)\n\t}\n\n\treturn p.sendMediaMessage(ctx, rc, larkim.MsgTypeMedia, mediaContent)\n}\n\ntype postElement struct {\n\tTag      string `json:\"tag\"`\n\tText     string `json:\"text,omitempty\"`\n\tLanguage string `json:\"language,omitempty\"`","sourceCodeStart":5560,"sourceCodeEnd":5596,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5560-L5596","documentation":"The upload call reported success, but the response body contains no Data.FileKey, which is mandatory to construct the media message. This is treated as a malformed/unexpected API response and fails fast instead of sending a message with an empty file key.","triggerScenarios":"Im.File.Create returns Success()==true but uploadResp.Data is nil or Data.FileKey is nil — an unexpected response shape from Feishu (API behavior change, partial response, SDK version mismatch).","commonSituations":"Upgrading/using a mismatched larksuite/oapi-sdk version where response fields aren't deserialized; Feishu returns a success envelope without a file_key; proxy mangling the response body.","solutions":["Check the SDK version (github.com/larksuite/oapi-sdk-go) and upgrade to latest — field deserialization bugs are fixed in newer versions","Log the raw response body to confirm whether Feishu actually omitted file_key","Retry the upload; a transient gateway issue can produce truncated responses","Verify no response-modifying proxy/middleware is stripping the JSON body","If persistent, file an issue with Feishu support including request ID"],"exampleFix":"// before\nif uploadResp.Data == nil || uploadResp.Data.FileKey == nil {\n    return fmt.Errorf(\"%s: upload video: no file_key returned\", p.tag())\n}\n// after: retry once on missing key before giving up\nif uploadResp.Data == nil || uploadResp.Data.FileKey == nil {\n    // retry upload once, then fall back to the error\n    return fmt.Errorf(\"%s: upload video: no file_key returned\", p.tag())\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"if uploadResp.Data == nil || uploadResp.Data.FileKey == nil { /* retry or fail */ }","tryCatchPattern":null,"preventionTips":["Pin and regularly upgrade github.com/larksuite/oapi-sdk-go","Log raw upload responses when debugging","Retry uploads once on empty file_key"],"tags":["feishu","upload","unexpected-response","api"],"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"}