XTLS/Xray-core · error
failed to convert map to json
Error message
failed to convert map to json
What it means
Error "failed to convert map to json" thrown in XTLS/Xray-core.
Source
Thrown at infra/conf/serial/loader.go:121
return pbConfig, nil
}
// DecodeTOMLConfig reads from reader and decode the config into *conf.Config
// using github.com/pelletier/go-toml and map to convert toml to json.
func DecodeTOMLConfig(reader io.Reader) (*conf.Config, error) {
tomlFile, err := io.ReadAll(reader)
if err != nil {
return nil, errors.New("failed to read config file").Base(err)
}
configMap := make(map[string]interface{})
if err := toml.Unmarshal(tomlFile, &configMap); err != nil {
return nil, errors.New("failed to convert toml to map").Base(err)
}
jsonFile, err := json.Marshal(&configMap)
if err != nil {
return nil, errors.New("failed to convert map to json").Base(err)
}
return DecodeJSONConfig(bytes.NewReader(jsonFile))
}
func LoadTOMLConfig(reader io.Reader) (*core.Config, error) {
tomlConfig, err := DecodeTOMLConfig(reader)
if err != nil {
return nil, err
}
pbConfig, err := tomlConfig.Build()
if err != nil {
return nil, errors.New("failed to parse toml config").Base(err)
}
return pbConfig, nil
}View on GitHub (pinned to 7d214f8b09)
When it happens
Trigger: Thrown at infra/conf/serial/loader.go:121 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/de7cd8e4523e4d75.
Report an issue: GitHub.