Billionmail/BillionMail · error
error creating company profile file: %v
Error message
error creating company profile file: %v
What it means
When company_profile.json is missing, ReadCompanyProfile writes a serialized default profile with os.WriteFile (mode 0644). This error wraps that write failing. Note the parent directory PRODUCT_CONFIG_PATH/<domain> is never created here, so a missing domain directory (ENOENT) is the most common cause.
Source
Thrown at core/internal/service/askai/project.go:442
WebSite: "",
CompanyProfile: "",
Email: "",
Phone: "",
SupportUrl: "",
}
// If the company profile file does not exist, return a default profile
// This allows the system to handle cases where the profile has not been set up yet
// and avoids errors when trying to read a non-existent file.
// It also allows the user to create a new profile without needing to handle file not
// found errors.
companyProfileDefault.UpdateTime = public.GetNowTime()
companyProfileJson, err := json.MarshalIndent(companyProfileDefault, "", " ")
if err != nil {
return CompanyProfile{}, fmt.Errorf("error marshalling company profile: %v", err)
}
err = os.WriteFile(filename, companyProfileJson, 0644)
if err != nil {
return CompanyProfile{}, fmt.Errorf("error creating company profile file: %v", err)
}
return companyProfileDefault, nil
}
data, err := os.ReadFile(filename)
if err != nil {
return CompanyProfile{}, fmt.Errorf("error reading company profile file: %v", err)
}
var profile CompanyProfile
err = json.Unmarshal(data, &profile)
if err != nil {
return CompanyProfile{}, fmt.Errorf("error unmarshalling company profile: %v", err)
}
return profile, nil
}
// SaveCompanyProfile saves the provided CompanyProfile to a JSON file based on the domain.
// It creates the directory if it does not exist and writes the profile information to company_profile.json
func SaveCompanyProfile(Domain string, profile CompanyProfile) error {View on GitHub (pinned to fc36c76c05)
Solutions
- Read the wrapped %v error for the OS cause (ENOENT, EACCES, ENOSPC)
- Pre-create the domain directory: os.MkdirAll(fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s", Domain), 0o755) before WriteFile
- Ensure the process user has write permission on PRODUCT_CONFIG_PATH (chown/chmod, fix volume mount)
- Check disk space/quotas
Example fix
// before
err = os.WriteFile(filename, companyProfileJson, 0644)
// after
os.MkdirAll(filepath.Dir(filename), 0o755)
if err := os.WriteFile(filename, companyProfileJson, 0o644); err != nil {
return CompanyProfile{}, fmt.Errorf("error creating company profile file: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
func ensureDomainConfigDir(domain string) error {
return os.MkdirAll(fmt.Sprintf("%s/%s", PRODUCT_CONFIG_PATH, domain), 0o755)
}
// before first ReadCompanyProfile for a domain:
if err := ensureDomainConfigDir(domain); err != nil {
return err
} Try / catch
profile, err := ReadCompanyProfile(domain)
if err != nil && strings.Contains(err.Error(), "creating company profile file") {
log.Errorf("Cannot initialize company profile for %s: %v — check dir/permissions", domain, err)
// return empty default profile to degrade gracefully
} Prevention
- Create the domain config directory at domain provisioning time
- Ensure PRODUCT_CONFIG_PATH is on a writable volume for the service user
- Watch for ENOSPC via disk monitoring
- Validate PRODUCT_CONFIG_PATH configuration at startup
When it happens
Trigger: os.WriteFile fails while creating the default profile: parent directory PRODUCT_CONFIG_PATH/<domain> does not exist and is not auto-created (ENOENT); permission denied; read-only filesystem; disk full; company_profile.json path is a directory.
Common situations: First access for a brand-new domain whose config directory was never created; read-only container volume; service user lacking write access to PRODUCT_CONFIG_PATH; PRODUCT_CONFIG_PATH misconfigured.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error reading project configuration file: %v
- error writing project configuration file: %v
- error writing knowledge base file: %v
- error reading company profile file: %v
- error saving prompt config file: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/8bb2cfb92d7c0527.
Report an issue: GitHub.