XTLS/Xray-core · error

failed to decode config:

Error message

failed to decode config: 

What it means

Error "failed to decode config: " thrown in XTLS/Xray-core.

Source

Thrown at infra/conf/serial/builder.go:50

	}
	return "", errors.New("marshal to json failed.").AtError()
}

func mergeConfigs(files []*core.ConfigSource) (*conf.Config, error) {
	cf := &conf.Config{}
	for i, file := range files {
		errors.LogInfo(context.Background(), "Reading config: ", file)
		r, err := confloader.LoadConfig(file.Name)
		if err != nil {
			return nil, errors.New("failed to read config: ", file).Base(err)
		}
		decoder := ReaderDecoderByFormat[file.Format]
		if file.Format == "json" && UseStrictJSON {
			decoder = DecodeJSONConfigStrict
		}
		c, err := decoder(r)
		if err != nil {
			return nil, errors.New("failed to decode config: ", file).Base(err)
		}
		if i == 0 {
			*cf = *c
			continue
		}
		cf.Override(c, file.Name)
	}
	return cf, nil
}

func BuildConfig(files []*core.ConfigSource) (*core.Config, error) {
	config, err := mergeConfigs(files)
	if err != nil {
		return nil, err
	}
	return config.Build()
}

View on GitHub (pinned to 7d214f8b09)

When it happens

Trigger: Thrown at infra/conf/serial/builder.go:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/ac6f19582f1849af. Report an issue: GitHub.