{"record":{"id":"4013f82deede73d8","repo":"crowdsecurity/crowdsec","slug":"parsing-w-4013f8","errorCode":null,"errorMessage":"parsing: %w","messagePattern":"parsing: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":122,"sourceCode":"\nfunc NewTest(name string, hubTest *HubTest, dataDir string) (*HubTestItem, error) {\n\ttestPath := filepath.Join(hubTest.HubTestPath, name)\n\truntimeFolder := filepath.Join(testPath, \"runtime\")\n\truntimeHubFolder := filepath.Join(runtimeFolder, \"hub\")\n\tconfigFilePath := filepath.Join(testPath, \"config.yaml\")\n\tresultPath := filepath.Join(testPath, \"results\")\n\n\t// read test configuration file\n\tconfigFileData := &HubTestItemConfig{}\n\n\tyamlFile, err := os.ReadFile(configFilePath)\n\tif err != nil {\n\t\tlog.Printf(\"no config file found in '%s': %v\", testPath, err)\n\t}\n\n\terr = yaml.Unmarshal(yamlFile, configFileData)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing: %w\", err)\n\t}\n\n\tparserAssertFilePath := filepath.Join(testPath, ParserAssertFileName)\n\tparserAssert := NewParserAssert(parserAssertFilePath)\n\n\tscenarioAssertFilePath := filepath.Join(testPath, ScenarioAssertFileName)\n\tscenarioAssert := NewScenarioAssert(scenarioAssertFilePath)\n\n\t// force own_data_dir for backard compatibility\n\tif name == \"magento-ccs-by-as\" || name == \"magento-ccs-by-country\" || name == \"geoip-enrich\" {\n\t\tconfigFileData.OwnDataDir = true\n\t}\n\n\tif configFileData.OwnDataDir {\n\t\tdataDir = filepath.Join(runtimeFolder, \"data\")\n\t}\n\n\treturn &HubTestItem{","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L104-L140","documentation":"NewTest reads the test directory's config file and unmarshals it with yaml.Unmarshal; a syntax/type error in the YAML is wrapped as 'parsing: %w'. (A missing config file is only logged earlier, so this specific error means the file existed but could not be parsed.)","triggerScenarios":"LoadTestItem -> NewTest with a config.yaml (or equivalent) whose content is invalid YAML: bad indentation, tabs, duplicate keys the decoder rejects, or fields of the wrong type.","commonSituations":"Hand-editing test config and mixing tabs/spaces; forgetting to quote values containing colons; merging upstream test changes with local edits; pasting YAML from docs with smart quotes.","solutions":["Read the wrapped YAML library error in the message; it usually names the exact line/column.","Fix indentation (spaces, never tabs) and quoting in the test's config.yaml.","Validate the file with a YAML linter/parser before re-running the test.","Restore the original file from git if local edits caused it: `git checkout -- tests/<name>/config.yaml`."],"exampleFix":"// before (config.yaml)\nparsers:\n\t- foo\n// after (use spaces)\nparsers:\n  - foo","handlingStrategy":"validation","validationCode":"import \"gopkg.in/yaml.v3\"\nfunc validYAML(b []byte) error {\n    var v map[string]interface{}\n    return yaml.Unmarshal(b, &v)\n}","typeGuard":null,"tryCatchPattern":"_, err := h.LoadTestItem(name)\nvar ye *yaml.TypeError\nif errors.As(err, &inner) && strings.Contains(err.Error(), \"parsing:\") {\n    log.Printf(\"fix YAML in %s/config.yaml: %v\", name, inner)\n}","preventionTips":["Use spaces, never tabs, in test config.yaml files.","Quote values containing ':' or special characters.","Run a YAML linter on edited test configs before committing."],"tags":["yaml","hubtest","parsing"],"backgroundTag":"yaml-parse-error","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"}