{"record":{"id":"f2e9ba11f79be9a4","repo":"XTLS/Xray-core","slug":"failed-to-convert-yaml-to-json","errorCode":null,"errorMessage":"failed to convert yaml to json","messagePattern":"failed to convert yaml to json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/serial/loader.go","lineNumber":151,"sourceCode":"\tpbConfig, err := tomlConfig.Build()\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to parse toml config\").Base(err)\n\t}\n\n\treturn pbConfig, nil\n}\n\n// DecodeYAMLConfig reads from reader and decode the config into *conf.Config\n// using github.com/ghodss/yaml to convert yaml to json.\nfunc DecodeYAMLConfig(reader io.Reader) (*conf.Config, error) {\n\tyamlFile, err := io.ReadAll(reader)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to read config file\").Base(err)\n\t}\n\n\tjsonFile, err := yaml.YAMLToJSON(yamlFile)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to convert yaml to json\").Base(err)\n\t}\n\n\treturn DecodeJSONConfig(bytes.NewReader(jsonFile))\n}\n\nfunc LoadYAMLConfig(reader io.Reader) (*core.Config, error) {\n\tyamlConfig, err := DecodeYAMLConfig(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpbConfig, err := yamlConfig.Build()\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to parse yaml config\").Base(err)\n\t}\n\n\treturn pbConfig, nil\n}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/serial/loader.go#L133-L169","documentation":"Error \"failed to convert yaml to json\" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at infra/conf/serial/loader.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}