XTLS/Xray-core · error
failed to parse remote JSON config
Error message
failed to parse remote JSON config
What it means
Raised in DecodeJSONConfigStrict when strict RFC 8259 json.Unmarshal fails on a remote config payload: the remote source returned JSON containing JSON5/JSONC extensions (comments, trailing commas) or syntax errors, which strict mode rejects by design.
Solutions
- Serve machine-generated strict JSON from the remote source (no comments/trailing commas)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at infra/conf/serial/loader.go:87 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/7fded76d61e83a85.
Report an issue: GitHub.
Appendix: source
Thrown at infra/conf/serial/loader.go:87
return nil, errors.New("failed to read config file").Base(err)
}
return jsonConfig, nil
}
// DecodeJSONConfigStrict reads standard RFC 8259 JSON without comment-stripping.
// Used for remote sources (http/https/http+unix) where the payload is produced by
// automated systems and cannot contain JSON5/JSONC extensions. Avoids the
// byte-by-byte comment stripper and TeeReader, which are significant overhead on
// large configs.
func DecodeJSONConfigStrict(reader io.Reader) (*conf.Config, error) {
data, err := io.ReadAll(reader)
if err != nil {
return nil, errors.New("failed to read config file").Base(err)
}
jsonConfig := &conf.Config{}
if err := json.Unmarshal(data, jsonConfig); err != nil {
return nil, errors.New("failed to parse remote JSON config").Base(err)
}
return jsonConfig, nil
}
func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
jsonConfig, err := DecodeJSONConfig(reader)
if err != nil {
return nil, err
}
pbConfig, err := jsonConfig.Build()
if err != nil {
return nil, errors.New("failed to parse json config").Base(err)
}
return pbConfig, nil
}
View on GitHub (pinned to 7d214f8b09)