{"record":{"id":"c92d771e4703fcb7","repo":"Billionmail/BillionMail","slug":"error-marshalling-style-config-v","errorCode":null,"errorMessage":"error marshalling style config: %v","messagePattern":"error marshalling style config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/project.go","lineNumber":541,"sourceCode":"\tfilename := fmt.Sprintf(PRODUCT_CONFIG_PATH+\"/%s/style_config.json\", Domain)\n\tif !public.FileExists(filename) {\n\t\tstyleConfigDefault := StyleConfig{\n\t\t\tAccentColor:         \"#007bff\",           // Default accent color\n\t\t\tTextColor:           \"#000000\",           // Default text color\n\t\t\tPageBackground:      \"#ffffff\",           // Default page background color\n\t\t\tContainerBackground: \"#f8f9fa\",           // Default container background color\n\t\t\tLinkSocialColor:     \"#007bff\",           // Default social link color\n\t\t\tLinkFooterColor:     \"#6c757d\",           // Default footer link color\n\t\t\tHeadingFont:         \"Arial, sans-serif\", // Default heading font\n\t\t\tBodyFont:            \"Arial, sans-serif\", // Default body font\n\t\t\tUpdateTime:          public.GetNowTime(), // Current time as update time\n\t\t}\n\t\t// If the style config file does not exist, return a default style config\n\t\t// This allows the system to handle cases where the style configuration has not been set up yet\n\t\t// and avoids errors when trying to read a non-existent file.\n\t\tstyleConfigJson, err := json.MarshalIndent(styleConfigDefault, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn StyleConfig{}, fmt.Errorf(\"error marshalling style config: %v\", err)\n\t\t}\n\t\terr = os.WriteFile(filename, styleConfigJson, 0644)\n\t\tif err != nil {\n\t\t\treturn StyleConfig{}, fmt.Errorf(\"error saving style config file: %v\", err)\n\t\t}\n\t\treturn styleConfigDefault, nil\n\t}\n\tdata, err := os.ReadFile(filename)\n\tif err != nil {\n\t\treturn StyleConfig{}, fmt.Errorf(\"error reading style config file: %v\", err)\n\t}\n\n\tvar config StyleConfig\n\terr = json.Unmarshal(data, &config)\n\tif err != nil {\n\t\treturn StyleConfig{}, fmt.Errorf(\"error unmarshalling style config: %v\", err)\n\t}\n\treturn config, nil","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/project.go#L523-L559","documentation":"Raised in GetStyleConfig while seeding a missing style_config.json: the built-in default StyleConfig (accent/text/background colors, fonts) could not be serialized by json.MarshalIndent. Since the default struct is hard-coded and JSON-safe, this is effectively unreachable defensive code; a struct regression (unsupported field type) is the only realistic trigger.","triggerScenarios":"Thrown at core/internal/service/askai/project.go:541 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat this error as a code-regression signal: diff StyleConfig for newly added non-serializable fields","Keep StyleConfig limited to string/int64 fields or annotate complex fields with json:\"-\"","Add a test asserting the default StyleConfig marshals successfully"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}