Billionmail/BillionMail · error
error reading images configuration: %v
Error message
error reading images configuration: %v
What it means
UploadImage returns this when the post-upload call to ReadImagesConfig fails, wrapping the underlying read error (file unreadable) or unmarshal error. The upload itself succeeded, but the local images.json bookkeeping could not be loaded, so the image record is not appended.
Source
Thrown at core/internal/service/askai/project.go:966
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
}
// ModifyImage updates the alt text and image tag of an existing image in the images configuration.
// It reads the existing images configuration, modifies the specified fields for the image with the given ID and saves the updated configuration back to the file.
// If the images configuration file does not exist or cannot be read, it returns an error.
func ModifyImage(Domain string, ImageId string, AltText string, ImageTag string) error {
images, err := ReadImagesConfig(Domain)
if err != nil {
return fmt.Errorf("error reading images configuration: %v", err)
}View on GitHub (pinned to fc36c76c05)
Solutions
- Fix the underlying ReadImagesConfig error (inspect the wrapped cause in the log).
- Ensure PRODUCT_CONFIG_PATH/<Domain> exists with correct permissions before uploads.
- Repair or reset a corrupt images.json (validate with jq).
- Make ReadImagesConfig resilient: MkdirAll before seeding and fall back to empty slice when appropriate.
Example fix
// before
images, err := ReadImagesConfig(Domain)
if err != nil {
return "", fmt.Errorf("error reading images configuration: %v", err)
}
// after
images, err := ReadImagesConfig(Domain)
if err != nil {
logger.Warnf("read images config failed, starting empty: %v", err)
images = []ImageInfo{}
} Defensive patterns
Strategy: try-catch
Validate before calling
p := filepath.Join(PRODUCT_CONFIG_PATH, Domain, "images.json")
if _, err := os.Stat(p); err != nil {
os.MkdirAll(filepath.Dir(p), 0755)
}
// validate existing JSON parses before upload:
var probe []ImageInfo
if data, err := os.ReadFile(p); err == nil && len(data) > 0 {
if json.Unmarshal(data, &probe) != nil {
return fmt.Errorf("images.json corrupt before upload")
}
} Try / catch
url, err := UploadImage(domain, imagePath, info)
if err != nil && strings.Contains(err.Error(), "error reading images configuration") {
// upload succeeded but metadata not saved; retry save or reconcile later
log.Printf("persist image record failed: %v", err)
} Prevention
- Harden ReadImagesConfig with MkdirAll and error-checked seeding
- Fix JSON corruption before running upload flows
- Atomic writes to avoid truncated files
- Reconcile CDN images against local records after failures
When it happens
Trigger: UploadImage succeeds on the CDN but images.json is unreadable (permissions, missing directory causing the seeding write to fail) or contains corrupt JSON that makes ReadImagesConfig return an error.
Common situations: Permission drift after deployment; corrupt images.json from a concurrent write; PRODUCT_CONFIG_PATH changed between upload and read in the same process.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- error marshalling knowledge base: %v
- error reading knowledge base: %v
- error saving images file: %v
- error reading images configuration file: %v
- error unmarshalling images configuration: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/019dc7f390fd0a49.
Report an issue: GitHub.