{"record":{"id":"8029bb9e72512d77","repo":"crowdsecurity/crowdsec","slug":"unable-to-serialize-overrides-w","errorCode":null,"errorMessage":"unable to serialize overrides: %w","messagePattern":"unable to serialize overrides: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":221,"sourceCode":"\n\tif err := t.installHubItems(t.Config.PostOverflows, t.installPostoverflow); err != nil {\n\t\treturn err\n\t}\n\n\tif err := t.installHubItems(t.Config.AppsecRules, t.installAppsecRule); err != nil {\n\t\treturn err\n\t}\n\n\tif len(t.Config.OverrideStatics) > 0 {\n\t\tcfg := parser.NodeConfig{\n\t\t\tName:    \"overrides\",\n\t\t\tFilter:  \"1==1\",\n\t\t\tStatics: t.Config.OverrideStatics,\n\t\t}\n\n\t\tb, err := yaml.Marshal(cfg)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to serialize overrides: %w\", err)\n\t\t}\n\n\t\ttgtFilename := fmt.Sprintf(\"%s/parsers/s00-raw/00_overrides.yaml\", t.RuntimePath)\n\t\tif err := os.WriteFile(tgtFilename, b, os.ModePerm); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write overrides to '%s': %w\", tgtFilename, err)\n\t\t}\n\t}\n\n\t// load installed hub\n\thub, err := cwhub.NewHub(t.RuntimeHubConfig, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := hub.Load(); err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L203-L239","documentation":"InstallHub, when the test defines override statics, marshals a parser config containing them with yaml.Marshal to produce 00_overrides.yaml. If marshaling fails the error is wrapped as 'unable to serialize overrides: %w'. This is rare — yaml.Marshal only fails for unsupported types (e.g. channels, funcs) in the data.","triggerScenarios":"Calling HubTestItem.Run (via InstallHub) on a test whose Config.OverrideStatics contains values that the YAML marshaller cannot represent.","commonSituations":"Custom or programmatically built HubTestItem configs where override statics were populated with non-marshalable values instead of plain strings/maps; version upgrades introducing new field types into the parsed config struct.","solutions":["Inspect the wrapped error for the unsupported type and fix the OverrideStatics content in the test's config.yaml.","Keep override statics as simple scalar/map values (strings, ints, bools) in the test config.","If triggered programmatically, convert the offending field to a plain serializable value before calling Run."],"exampleFix":"// before\nstatics: [{name: target_uri, value: !!binary aGk=, type: \"unsupported\"}]\n// after\nstatics:\n  - name: target_uri\n    value: http://127.0.0.1:8080\n    type: string","handlingStrategy":"try-catch","validationCode":"for _, s := range item.Config.OverrideStatics {\n    if _, err := yaml.Marshal(s); err != nil {\n        log.Printf(\"non-marshalable override static: %+v\", s)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := item.Run(ctx)\nif err != nil && strings.Contains(err.Error(), \"unable to serialize overrides\") {\n    log.Printf(\"fix OverrideStatics values in %s config: %v\", item.Name, err)\n}","preventionTips":["Keep OverrideStatics values to plain strings/numbers/bools in test configs.","Avoid custom YAML tags in override statics."],"tags":["yaml","serialization","hubtest"],"backgroundTag":"json-serialization-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}