Billionmail/BillionMail · warning
error marshalling company profile: %v
Error message
error marshalling company profile: %v
What it means
ReadCompanyProfile lazily creates a default company_profile.json when none exists for the domain. This error wraps json.MarshalIndent of the default CompanyProfile failing. With the all-string default struct this is essentially unreachable; it would require a struct field of unmarshalable type or a failing custom MarshalJSON introduced by future changes.
Source
Thrown at core/internal/service/askai/project.go:438
filename := fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s/company_profile.json", Domain)
if !public.FileExists(filename) {
companyProfileDefault := CompanyProfile{
LegalCompanyName: "",
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
}View on GitHub (pinned to fc36c76c05)
Solutions
- Check the wrapped %v error for json.UnsupportedTypeError and the offending field
- Tag runtime-only fields with json:"-" or give them JSON-safe types
- Fix any custom MarshalJSON on CompanyProfile or its fields
Example fix
// before Conn net.Conn // unsupported type breaks MarshalIndent // after Conn net.Conn `json:"-"` // excluded from serialization
Defensive patterns
Strategy: type-guard
Validate before calling
if err := json.Marshal(CompanyProfile{}); err != nil {
// struct gained an unmarshalable field; fix before runtime
} Type guard
func profileIsSerializable(p CompanyProfile) bool {
_, err := json.Marshal(p)
return err == nil
} Try / catch
profile, err := ReadCompanyProfile(domain)
if err != nil && strings.Contains(err.Error(), "marshalling company profile") {
log.Errorf("CompanyProfile struct not serializable: %v", err)
} Prevention
- Tag runtime-only fields on CompanyProfile with json:"-"
- Add a regression test that marshals a fully populated CompanyProfile
- Review new struct fields for JSON compatibility before merging
When it happens
Trigger: json.MarshalIndent(companyProfileDefault, ...) errors — e.g. someone adds a non-JSON-serializable field (chan/func/cyclic) to CompanyProfile, or a custom MarshalJSON returns an error.
Common situations: Post-change regression: a developer adds a runtime-only field (mutex, connection handle) to CompanyProfile without a json:"-" tag or marshals an unsupported type.
Related errors
- error marshalling project configuration: %v
- error marshalling knowledge base: %v
- error marshalling empty site map: %v
- error marshalling site map: %v
- error marshalling default footer config: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/ab721c3ca398f523.
Report an issue: GitHub.