{"record":{"id":"2a88ff0e865c1d91","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-parse-data-file-w","errorCode":null,"errorMessage":"failed to parse data file: %w","messagePattern":"failed to parse data file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/data.go","lineNumber":177,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn dataFromRoot(root)\n}\n\n// decodeDataRoot decodes raw into a generic map of raw JSON messages,\n// dispatching on ext exactly as LoadData's own format switch used to do\n// inline, before ParseData needed the same switch for its one fixed format.\nfunc decodeDataRoot(ext string, raw []byte) (map[string]json.RawMessage, error) {\n\tvar root map[string]json.RawMessage\n\n\tswitch ext {\n\tcase JSON, JSONC:\n\t\traw = []byte(text.StripJSONComments(string(raw)))\n\n\t\tif err := json.Unmarshal(raw, &root); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse data file: %w\", err)\n\t\t}\n\tcase YAML, YML:\n\t\tvar generic map[string]any\n\n\t\tif err := yaml.Unmarshal(raw, &generic); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse data file: %w\", err)\n\t\t}\n\n\t\tnormalized, err := normalize(generic)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse data file: %w\", err)\n\t\t}\n\n\t\troot = normalized\n\tcase TOML, TML:\n\t\tvar generic map[string]any\n\n\t\tif err := toml.Unmarshal(raw, &generic); err != nil {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/config/data.go#L159-L195","documentation":"After reading the data file, decodeDataRoot unmarshals content based on file extension. For .json/.jsonc files, JSON comments are stripped and json.Unmarshal runs; on failure this wrapped error is returned. The file was readable but its contents are not valid JSON (or JSONC after comment stripping).","triggerScenarios":"Loading a .json/.jsonc data file containing a syntax error: trailing comma, unquoted key, stray comment not recognized, truncated file, or BOM/encoding issues.","commonSituations":"Hand-edited theme/data configs left malformed, a merge conflict marker (<<<<<<<) left in the file, copying YAML content into a .json file, or a tool writing partial output on crash.","solutions":["Run the file through a JSON linter/parser to locate the syntax error","Remove trailing commas and ensure keys/strings are double-quoted","Remove leftover git merge-conflict markers","Confirm the file extension matches the actual content format (rename to .yaml if it is YAML)"],"exampleFix":"// before (data.json)\n{ \"version\": 1, }\n// after\n{ \"version\": 1 }","handlingStrategy":"validation","validationCode":"var probe any\nif err := json.Unmarshal(raw, &probe); err != nil {\n    return fmt.Errorf(\"invalid JSON in %s: %w\", path, err)\n}","typeGuard":"func isValidJSON(raw []byte) bool { var v any; return json.Unmarshal(raw, &v) == nil }","tryCatchPattern":"data, err := config.LoadData(path)\nif err != nil && strings.Contains(err.Error(), \"failed to parse data file\") {\n    log.Fatalf(\"malformed JSON in %s: %v\", path, errors.Unwrap(err))\n}","preventionTips":["Run a JSON linter after hand edits","Remove merge-conflict markers before saving","Keep comments in .jsonc files only, plain JSON in .json","Match file extension to actual content format"],"tags":["json","parsing","config"],"backgroundTag":"config-parse-error","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}