{"record":{"id":"9a1b460702b9eaef","repo":"Billionmail/BillionMail","slug":"error-unmarshalling-company-profile-v","errorCode":null,"errorMessage":"error unmarshalling company profile: %v","messagePattern":"error unmarshalling company profile: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/project.go","lineNumber":453,"sourceCode":"\t\tcompanyProfileDefault.UpdateTime = public.GetNowTime()\n\t\tcompanyProfileJson, err := json.MarshalIndent(companyProfileDefault, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn CompanyProfile{}, fmt.Errorf(\"error marshalling company profile: %v\", err)\n\t\t}\n\t\terr = os.WriteFile(filename, companyProfileJson, 0644)\n\t\tif err != nil {\n\t\t\treturn CompanyProfile{}, fmt.Errorf(\"error creating company profile file: %v\", err)\n\t\t}\n\t\treturn companyProfileDefault, nil\n\t}\n\tdata, err := os.ReadFile(filename)\n\tif err != nil {\n\t\treturn CompanyProfile{}, fmt.Errorf(\"error reading company profile file: %v\", err)\n\t}\n\tvar profile CompanyProfile\n\terr = json.Unmarshal(data, &profile)\n\tif err != nil {\n\t\treturn CompanyProfile{}, fmt.Errorf(\"error unmarshalling company profile: %v\", err)\n\t}\n\treturn profile, nil\n}\n\n// SaveCompanyProfile saves the provided CompanyProfile to a JSON file based on the domain.\n// It creates the directory if it does not exist and writes the profile information to company_profile.json\nfunc SaveCompanyProfile(Domain string, profile CompanyProfile) error {\n\tfilename := fmt.Sprintf(PRODUCT_CONFIG_PATH+\"/%s/company_profile.json\", Domain)\n\tdata, err := json.Marshal(profile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling company profile: %v\", err)\n\t}\n\terr = os.WriteFile(filename, data, 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error saving company profile file: %v\", err)\n\t}\n\treturn nil\n}","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/project.go#L435-L471","documentation":"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.","triggerScenarios":"Thrown at core/internal/service/askai/project.go:453 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the domain's company_profile.json on disk for truncation or manual edits and restore it from a known-good copy","Validate the file with a JSON linter (e.g. jq . company_profile.json) to pinpoint the syntax error","If the content is unrecoverable, delete the file so ReadCompanyProfile regenerates the default profile on next call","Verify the struct fields match the JSON keys; drift between CompanyProfile and the stored file causes type mismatches"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}