{"record":{"id":"1fa9a1a224252aee","repo":"Billionmail/BillionMail","slug":"upload-image-failed-s","errorCode":null,"errorMessage":"upload image failed: %s","messagePattern":"upload image failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/project.go","lineNumber":958,"sourceCode":"\t}\n\tapiUrl := fmt.Sprintf(\"%s/upload-image\", FILE_CDN_API)\n\tparams := url.Values{}\n\tparams.Set(\"imageId\", imageInfo.ImageId)\n\tparams.Set(\"imageBase64\", Image)\n\tparams.Set(\"imageFilename\", Filename)\n\n\tresult, err := public.HttpPostSrc(apiUrl, params, 60)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar resultData UploadImageResponse\n\terr = json.Unmarshal([]byte(result), &resultData)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resultData.Status == false {\n\t\treturn \"\", fmt.Errorf(\"upload image failed: %s\", resultData.Msg)\n\t}\n\n\timageInfo.ImageUrl = resultData.Data.URL\n\n\t// Save the image information to the images.json file\n\timages, err := ReadImagesConfig(Domain)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error reading images configuration: %v\", err)\n\t}\n\timages = append(images, imageInfo)\n\terr = SaveImagesConfig(Domain, images)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error saving images configuration: %v\", err)\n\t}\n\n\treturn imageInfo.ImageUrl, nil\n}\n","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/project.go#L940-L976","documentation":"UploadImage returns this when the CDN upload API responds with status=false; the library surfaces the API's own message (resultData.Msg) verbatim. It is a remote-service rejection, not a local failure.","triggerScenarios":"Calling UploadImage when FILE_CDN_API rejects the upload: invalid/missing auth token, oversized or unsupported image type, CDN service outage returning an error payload, or empty result string yielding Status=false.","commonSituations":"CDN credentials rotated or expired; uploading a file larger than the CDN limit; FILE_CDN_API pointing to the wrong environment; CDN maintenance window.","solutions":["Read resultData.Msg from the error to see the CDN's rejection reason and fix accordingly (auth, size, format).","Validate the file (size, MIME type) before uploading.","Verify FILE_CDN_API points to the correct, reachable CDN endpoint and credentials are current.","Add a retry with backoff for transient CDN errors, and check CDN service health."],"exampleFix":"// before\nif resultData.Status == false {\n\treturn \"\", fmt.Errorf(\"upload image failed: %s\", resultData.Msg)\n}\n// after\nif resultData.Status == false {\n\treturn \"\", fmt.Errorf(\"upload image failed (status=%v msg=%q)\", resultData.Status, resultData.Msg)\n}","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stat(imagePath); err != nil || fi.Size() > maxUploadBytes {\n\treturn fmt.Errorf(\"image too large or unreadable\")\n}\n// also verify FILE_CDN_API is set and reachable before upload","typeGuard":null,"tryCatchPattern":"url, err := UploadImage(domain, imagePath, imageInfo)\nif err != nil && strings.HasPrefix(err.Error(), \"upload image failed\") {\n\tlog.Printf(\"CDN rejected upload: %v\", err) // inspect resultData.Msg in message\n\t// retry with backoff or surface to user\n}","preventionTips":["Validate image size/MIME type before upload","Keep CDN credentials and FILE_CDN_API current per environment","Monitor CDN service health","Log the full error so resultData.Msg guides the fix"],"tags":["network","cdn","upload"],"backgroundTag":"cdn-upload-rejected","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}