Billionmail/BillionMail · error

upload image failed: %s

Error message

upload image failed: %s

What it means

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.

Source

Thrown at core/internal/service/askai/project.go:958

	}
	apiUrl := fmt.Sprintf("%s/upload-image", FILE_CDN_API)
	params := url.Values{}
	params.Set("imageId", imageInfo.ImageId)
	params.Set("imageBase64", Image)
	params.Set("imageFilename", Filename)

	result, err := public.HttpPostSrc(apiUrl, params, 60)
	if err != nil {
		return "", err
	}
	var resultData UploadImageResponse
	err = json.Unmarshal([]byte(result), &resultData)
	if err != nil {
		return "", err
	}

	if resultData.Status == false {
		return "", fmt.Errorf("upload image failed: %s", resultData.Msg)
	}

	imageInfo.ImageUrl = resultData.Data.URL

	// Save the image information to the images.json file
	images, err := ReadImagesConfig(Domain)
	if err != nil {
		return "", fmt.Errorf("error reading images configuration: %v", err)
	}
	images = append(images, imageInfo)
	err = SaveImagesConfig(Domain, images)
	if err != nil {
		return "", fmt.Errorf("error saving images configuration: %v", err)
	}

	return imageInfo.ImageUrl, nil
}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Read resultData.Msg from the error to see the CDN's rejection reason and fix accordingly (auth, size, format).
  2. Validate the file (size, MIME type) before uploading.
  3. Verify FILE_CDN_API points to the correct, reachable CDN endpoint and credentials are current.
  4. Add a retry with backoff for transient CDN errors, and check CDN service health.

Example fix

// before
if resultData.Status == false {
	return "", fmt.Errorf("upload image failed: %s", resultData.Msg)
}
// after
if resultData.Status == false {
	return "", fmt.Errorf("upload image failed (status=%v msg=%q)", resultData.Status, resultData.Msg)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if fi, err := os.Stat(imagePath); err != nil || fi.Size() > maxUploadBytes {
	return fmt.Errorf("image too large or unreadable")
}
// also verify FILE_CDN_API is set and reachable before upload

Try / catch

url, err := UploadImage(domain, imagePath, imageInfo)
if err != nil && strings.HasPrefix(err.Error(), "upload image failed") {
	log.Printf("CDN rejected upload: %v", err) // inspect resultData.Msg in message
	// retry with backoff or surface to user
}

Prevention

When it happens

Trigger: 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.

Common situations: CDN credentials rotated or expired; uploading a file larger than the CDN limit; FILE_CDN_API pointing to the wrong environment; CDN maintenance window.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/1fa9a1a224252aee. Report an issue: GitHub.