thanos-io/thanos · error

parsing config tracing YAML

Error message

parsing config tracing YAML

What it means

NewTracer in pkg/tracing/client/factory.go parses the tracing configuration YAML with yaml.UnmarshalStrict into TracingConfig. This error wraps any failure to parse that YAML, including unknown fields because strict unmarshalling is used. It indicates the tracing config content supplied to NewTracer is not valid YAML or does not match the TracingConfig schema.

Solutions

  1. Validate the YAML with a linter and confirm it only contains 'type' and 'config' keys
  2. Move backend-specific settings (e.g. Jaeger agent/sampler options) under the nested 'config' key, not the top level
  3. Fix YAML indentation/typos so it unmarshals cleanly
  4. Enable only supported fields for the chosen tracing type per docs

Example fix

// before
tracing:
  typ: jaeger
  agent_host: localhost
// after
tracing:
  type: JAEGER
  config:
    agent_host: localhost
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate before calling NewTracer
var probe map[string]interface{}
if err := yaml.Unmarshal(confContentYaml, &probe); err != nil {
    return fmt.Errorf("tracing config is not valid YAML: %w", err)
}
for _, k := range []string{"type", "config"} {
    if _, ok := probe[k]; !ok && k == "type" {
        return fmt.Errorf("tracing config missing required field 'type'")
    }
}
if _, ok := probe["typ"]; ok {
    return fmt.Errorf("tracing config has unknown key 'typ'; strict mode will reject it")
}

Try / catch

op, closer, err := tracing.NewTracer(ctx, logger, reg, cfgYaml)
if err != nil {
    if strings.Contains(err.Error(), "parsing config tracing YAML") {
        logger.Error(err, "fix tracing YAML: check syntax, unknown keys and nesting")
    }
    return err
}

Prevention

When it happens

Trigger: Calling NewTracer with confContentYaml that is malformed YAML, contains fields not defined in TracingConfig (strict mode rejects unknown keys), or has wrong types for 'type'/'config' fields.

Common situations: Typos in the tracing config block of the Thanos flag yaml file (e.g. 'typ: jaeger'), indentation errors, adding a vendor-specific key at the top level instead of under 'config', or passing an empty/placeholder file.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/a7429d8b45d65e5f. Report an issue: GitHub.

Appendix: source

Thrown at pkg/tracing/client/factory.go:47

	Stackdriver           TracingProvider = "STACKDRIVER"
	GoogleCloud           TracingProvider = "GOOGLE_CLOUD"
	Jaeger                TracingProvider = "JAEGER"
	ElasticAPM            TracingProvider = "ELASTIC_APM"
	Lightstep             TracingProvider = "LIGHTSTEP"
	OpenTelemetryProtocol TracingProvider = "OTLP"
)

type TracingConfig struct {
	Type   TracingProvider `yaml:"type"`
	Config any             `yaml:"config"`
}

func NewTracer(ctx context.Context, logger log.Logger, metrics *prometheus.Registry, confContentYaml []byte) (opentracing.Tracer, io.Closer, error) {
	level.Info(logger).Log("msg", "loading tracing configuration")
	tracingConf := &TracingConfig{}

	if err := yaml.UnmarshalStrict(confContentYaml, tracingConf); err != nil {
		return nil, nil, errors.Wrap(err, "parsing config tracing YAML")
	}

	var config []byte
	var err error
	if tracingConf.Config != nil {
		config, err = yaml.Marshal(tracingConf.Config)
		if err != nil {
			return nil, nil, errors.Wrap(err, "marshal content of tracing configuration")
		}
	}

	switch strings.ToUpper(string(tracingConf.Type)) {
	case string(Stackdriver), string(GoogleCloud):
		tracerProvider, err := google_cloud.NewTracerProvider(ctx, logger, config)
		if err != nil {
			return nil, nil, err
		}
		tracer, closerFunc := migration.Bridge(tracerProvider, logger)

View on GitHub (pinned to 35b8b99117)