{"record":{"id":"22212f7045b13280","repo":"wtfutil/wtf","slug":"failed-to-parse-yaml-in-config-file-s-w","errorCode":null,"errorMessage":"failed to parse YAML in config file %s: %w","messagePattern":"failed to parse YAML in config file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/azurelogs/config.go","lineNumber":53,"sourceCode":"\t\tsess.QueryFile = configFile\n\t} else {\n\t\treturn fmt.Errorf(\"invalid query file format: %s, expected .yaml\", filename)\n\t}\n\n\treturn nil\n}\n\n// readQueryFileContent reads a single config file and returns a QueryFile struct\nfunc readQueryFileContent(filePath string) (QueryFile, error) {\n\tvar configFile QueryFile\n\tdata, err := os.ReadFile(filePath)\n\tif err != nil {\n\t\treturn configFile, fmt.Errorf(\"failed to read query config file %s: %w\", filePath, err)\n\t}\n\n\terr = yaml.Unmarshal(data, &configFile)\n\tif err != nil {\n\t\treturn configFile, fmt.Errorf(\"failed to parse YAML in config file %s: %w\", filePath, err)\n\t}\n\n\treturn configFile, nil\n}\n","sourceCodeStart":35,"sourceCodeEnd":58,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/azurelogs/config.go#L35-L58","documentation":"This error is returned by readQueryFileContent in modules/azurelogs/config.go:53 when yaml.Unmarshal fails to parse the contents of the query config file into the config struct. It wraps the underlying YAML error, so the wrapped message pinpoints the offending line/column. The library throws it because a malformed YAML file cannot be safely turned into a Session QueryFile.","triggerScenarios":"Calling Init/readQueryFile with a query file whose content is not valid YAML: bad indentation, tabs instead of spaces, missing colon after a key, duplicate keys, or YAML special characters unquoted. Also produced by yaml tags in the file not matching the struct (caught by TestQueryFile_YAMLTags).","commonSituations":"Hand-edited query config files with wrong indentation (tabs are illegal in YAML), copy-pasted config losing indentation, unquoted values containing ':' or '#', or a query path pointing to a JSON/other non-YAML file.","solutions":["Open the file at the path named in the error and fix the YAML syntax at the line/column reported by the wrapped error","Validate the file with a YAML linter (e.g. yamllint or `python -c \"import yaml,sys; yaml.safe_load(open(sys.argv[1]))\" <file>`)","Replace tab characters with spaces for indentation","Quote values containing special characters like ':' or '#'"],"exampleFix":"// before (config.yml)\nworkspace:\n\tid: my-workspace  # tab indentation breaks YAML parser\n// after\nworkspace:\n  id: \"my-workspace\"  # spaces, quoted value","handlingStrategy":"validation","validationCode":"data, err := os.ReadFile(queryPath)\nif err != nil { return err }\nvar probe map[string]any\nif err := yaml.Unmarshal(data, &probe); err != nil {\n    return fmt.Errorf(\"invalid YAML in %s: %w\", queryPath, err)\n}","typeGuard":null,"tryCatchPattern":"sess, err := azurelogs.Init(&queryPath)\nif err != nil {\n    var yamlErr error\n    if errors.Unwrap(err) != nil { /* inspect wrapped cause */ }\n    log.Fatalf(\"query config invalid: %v\", err)\n}","preventionTips":["Lint query YAML files in CI with yamllint before deployment","Use spaces, never tabs, for YAML indentation","Keep query files in version control so bad edits are caught in review","Add a unit test that unmarshals every shipped query file at build time"],"tags":["yaml","config","parsing","azure"],"backgroundTag":"yaml-parse-error","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}