{"record":{"id":"28c0fbcf460b606f","repo":"chenhg5/cc-connect","slug":"s-upload-image-code-d-msg-s","errorCode":null,"errorMessage":"%s: upload image code=%d msg=%s","messagePattern":"(.+?): upload image code=(.+?) msg=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":3297,"sourceCode":"}\n\nfunc (p *Platform) uploadImageKey(ctx context.Context, data []byte) (string, error) {\n\tvar uploadResp *larkim.CreateImageResp\n\tif err := p.withTransientRetry(ctx, \"upload image\", func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, \"upload image\", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {\n\t\t\treq := larkim.NewCreateImageReqBuilder().\n\t\t\t\tBody(larkim.NewCreateImageReqBodyBuilder().\n\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}","sourceCodeStart":3279,"sourceCodeEnd":3315,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L3279-L3315","documentation":"The Feishu image upload API returned a response, but the response was not successful (uploadResp.Success() is false), i.e. Feishu returned a business error code and message. The library formats the API's code and msg fields so the caller can see exactly which Feishu-side error occurred.","triggerScenarios":"client.Im.Image.Create completes without transport error but uploadResp.Success() is false at platform/feishu/feishu.go:3297 — e.g. code 99991663/99991661 (token invalid), 230001 (invalid image file), or 1254006 (rate limited).","commonSituations":"App lacking im:resource scope, uploading a non-image or corrupted payload, exceeding Feishu image size limits (e.g. >10MB), or bot being rate-limited.","solutions":["Read the code=%d msg=%s values and look them up in Feishu's error code documentation.","Grant the app the im:resource permission and publish/enable the permission version.","Validate the image bytes (format, size under Feishu's limits) before upload.","Retry with backoff if the code indicates throttling (e.g. 1254xxx)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check permission scope before sending:\n// app must have im:resource enabled in Feishu open console","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var respErr *larkcore.APIError\n    if errors.As(err, &respErr) && respErr.Code == 99991663 {\n        // refresh token / fix credentials\n    }\n    return err\n}","preventionTips":["Always grant and publish im:resource permission for the Feishu app.","Pre-validate image format and size against Feishu limits.","Implement backoff for rate-limit codes (1254xxx).","Log code/msg pairs to spot recurring permission problems early."],"tags":["feishu","upload","api-error","permissions"],"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-14T00:17:10.932Z"}