Billionmail/BillionMail · error

error unmarshalling company profile: %v

Error message

error unmarshalling company profile: %v

What it means

Raised in ReadCompanyProfile when json.Unmarshal fails to decode the contents of PRODUCT_CONFIG_PATH/<domain>/company_profile.json into a CompanyProfile struct, i.e. the file exists but is truncated, empty, or contains invalid/foreign JSON. The underlying json error is wrapped with %v.

Source

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

		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 {
	filename := fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s/company_profile.json", Domain)
	data, err := json.Marshal(profile)
	if err != nil {
		return fmt.Errorf("error marshalling company profile: %v", err)
	}
	err = os.WriteFile(filename, data, 0644)
	if err != nil {
		return fmt.Errorf("error saving company profile file: %v", err)
	}
	return nil
}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Check the domain's company_profile.json on disk for truncation or manual edits and restore it from a known-good copy
  2. Validate the file with a JSON linter (e.g. jq . company_profile.json) to pinpoint the syntax error
  3. If the content is unrecoverable, delete the file so ReadCompanyProfile regenerates the default profile on next call
  4. Verify the struct fields match the JSON keys; drift between CompanyProfile and the stored file causes type mismatches
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at core/internal/service/askai/project.go:453 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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