{"record":{"id":"89c4eb83e4d4d1a6","repo":"XTLS/Xray-core","slug":"failed-to-read-config-file-at-line","errorCode":null,"errorMessage":"failed to read config file at line ","messagePattern":"failed to read config file at line ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/serial/loader.go","lineNumber":67,"sourceCode":"\tjsonConfig := &conf.Config{}\n\n\tjsonContent := bytes.NewBuffer(make([]byte, 0, 10240))\n\tjsonReader := io.TeeReader(&json_reader.Reader{\n\t\tReader: reader,\n\t}, jsonContent)\n\tdecoder := json.NewDecoder(jsonReader)\n\n\tif err := decoder.Decode(jsonConfig); err != nil {\n\t\tvar pos *offset\n\t\tcause := errors.Cause(err)\n\t\tswitch tErr := cause.(type) {\n\t\tcase *json.SyntaxError:\n\t\t\tpos = findOffset(jsonContent.Bytes(), int(tErr.Offset))\n\t\tcase *json.UnmarshalTypeError:\n\t\t\tpos = findOffset(jsonContent.Bytes(), int(tErr.Offset))\n\t\t}\n\t\tif pos != nil {\n\t\t\treturn nil, errors.New(\"failed to read config file at line \", pos.line, \" char \", pos.char).Base(err)\n\t\t}\n\t\treturn nil, errors.New(\"failed to read config file\").Base(err)\n\t}\n\n\treturn jsonConfig, nil\n}\n\n// DecodeJSONConfigStrict reads standard RFC 8259 JSON without comment-stripping.\n// Used for remote sources (http/https/http+unix) where the payload is produced by\n// automated systems and cannot contain JSON5/JSONC extensions. Avoids the\n// byte-by-byte comment stripper and TeeReader, which are significant overhead on\n// large configs.\nfunc DecodeJSONConfigStrict(reader io.Reader) (*conf.Config, error) {\n\tdata, err := io.ReadAll(reader)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to read config file\").Base(err)\n\t}\n\tjsonConfig := &conf.Config{}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/serial/loader.go#L49-L85","documentation":"Error \"failed to read config file at line \" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at infra/conf/serial/loader.go:67 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"}