{"record":{"id":"397a77ded083983b","repo":"crowdsecurity/crowdsec","slug":"serializing-console-context-s","errorCode":null,"errorMessage":"serializing console context: %s","messagePattern":"serializing console context: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/alertcontext/config.go","lineNumber":136,"sourceCode":"\t\tif _, err := os.Stat(c.Crowdsec.ConsoleContextPath); err != nil {\n\t\t\treturn fmt.Errorf(\"while checking console_context_path: %w\", err)\n\t\t}\n\t} else {\n\t\tc.Crowdsec.ConsoleContextPath = filepath.Join(c.ConfigPaths.ConfigDir, \"console\", \"context.yaml\")\n\t\tignoreMissing = true\n\t}\n\n\tif err := addContextFromFile(c.Crowdsec.ContextToSend, c.Crowdsec.ConsoleContextPath); err != nil {\n\t\tif !errors.Is(err, fs.ErrNotExist) {\n\t\t\treturn err\n\t\t} else if !ignoreMissing {\n\t\t\tlog.Warningf(\"while merging context from %s: %s\", c.Crowdsec.ConsoleContextPath, err)\n\t\t}\n\t}\n\n\tfeedback, err := json.Marshal(c.Crowdsec.ContextToSend)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"serializing console context: %s\", err)\n\t}\n\n\tlog.Debugf(\"console context to send: %s\", feedback)\n\n\treturn nil\n}\n","sourceCodeStart":118,"sourceCodeEnd":143,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/alertcontext/config.go#L118-L143","documentation":"At the end of LoadConsoleContext the assembled context map is JSON-marshaled as a sanity check; if marshaling fails the context data is not serializable (invalid types/keys), signaling corrupted context content.","triggerScenarios":"Thrown at pkg/alertcontext/config.go:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the context items and console context file for unusual data types","Fix malformed context values (must be string lists)","Report a bug if context content looks normal"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}