{"record":{"id":"d65dabc4850a4e3e","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-parse-version-in-data-file-w","errorCode":null,"errorMessage":"failed to parse version in data file: %w","messagePattern":"failed to parse version in data file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/data.go","lineNumber":220,"sourceCode":"\t\t}\n\n\t\troot = normalized\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported data file extension: %s\", ext)\n\t}\n\n\treturn root, nil\n}\n\n// dataFromRoot builds a Data from a generically-decoded document root,\n// shared by LoadData (any of its three formats) and ParseData (JSON only)\n// once each has the same map[string]json.RawMessage shape in hand.\nfunc dataFromRoot(root map[string]json.RawMessage) (*Data, error) {\n\tdata := &Data{}\n\n\tif versionRaw, OK := root[DataVersionKey]; OK {\n\t\tif err := json.Unmarshal(versionRaw, &data.Version); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse version in data file: %w\", err)\n\t\t}\n\t}\n\n\tif env, OK := root[DataEnvKey]; OK {\n\t\tdata.Env = env\n\t}\n\n\tif segmentsRaw, OK := root[DataSegmentsKey]; OK {\n\t\tvar segments map[string]json.RawMessage\n\n\t\tif err := json.Unmarshal(segmentsRaw, &segments); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse segments in data file: %w\", err)\n\t\t}\n\n\t\tdata.Segments = segments\n\t}\n\n\treturn data, nil","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/config/data.go#L202-L238","documentation":"Thrown by dataFromRoot when the optional top-level 'version' key exists in a data file but its value is not a valid JSON string. The version field is decoded with json.Unmarshal into data.Version; anything that is not a JSON string (number, object, array, or malformed value) fails and is wrapped with this message.","triggerScenarios":"Calling LoadData or ParseData on a data file containing a version key whose value is not a JSON string - e.g. version = 1 in TOML/YAML (decodes to a number), version: [1,2] in YAML, or version = true.","commonSituations":"Author assuming version is numeric and writing version = 2 in a TOML data file; quoting mistakes leaving the value as a number after format conversion; copy-pasting a schema-version integer from another tool.","solutions":["Make the version value a quoted string: version = \"2\" (TOML) or version: \"2\" (YAML)","Remove the version key entirely if versioning is not needed","Re-check the file after converting between formats - conversion tools often turn quoted strings into bare numbers"],"exampleFix":"// before (data.toml)\nversion = 2\n// after\nversion = \"2\"","handlingStrategy":"validation","validationCode":"func versionIsString(raw []byte) error {\n\tvar root map[string]json.RawMessage\n\tif err := json.Unmarshal(raw, &root); err != nil { return err }\n\tif v, ok := root[\"version\"]; ok {\n\t\tvar s string\n\t\treturn json.Unmarshal(v, &s)\n\t}\n\treturn nil\n}","typeGuard":"func versionIsString(root map[string]json.RawMessage) bool {\n\tvar s string\n\tv, ok := root[\"version\"]\n\treturn ok && json.Unmarshal(v, &s) == nil\n}","tryCatchPattern":"data, err := config.LoadData(path)\nif err != nil && strings.Contains(err.Error(), \"failed to parse version\") {\n\t// reject or auto-correct the data file before retrying\n}","preventionTips":["Always write version as a quoted string","Re-check files after running format converters (they unquote strings)","Omit the version key when not needed","Schema-validate data files in CI"],"tags":["json","config","version"],"backgroundTag":"data-version-parse-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}