SigNoz/signoz · error

ErrCodeInvalidCollectorConfig

ErrCodeInvalidCollectorConfig

Error message

failed to unmarshal collector config

What it means

GenerateCollectorConfigWithSpanMapperProcessor yaml.Unmarshals the provided collector config into map[string]any to append the span-mapper processor and wire it into pipelines. Unlike the LLM-pricing variant, empty input is not special-cased before unmarshal, so any invalid YAML (including empty bytes) fails here with ErrCodeInvalidCollectorConfig.

Source

Thrown at pkg/types/spantypes/spanmapperprocessor.go:57

	Attributes []string `yaml:"attributes,omitempty" json:"attributes,omitempty"`
	Resource   []string `yaml:"resource,omitempty" json:"resource,omitempty"`
}

type spanMapperProcessorAttribute struct {
	Target  string                      `yaml:"target" json:"target"`
	Context string                      `yaml:"context,omitempty" json:"context,omitempty"`
	Sources []spanMapperProcessorSource `yaml:"sources" json:"sources"`
}

type spanMapperProcessorSource struct {
	Key    string `yaml:"key" json:"key"`
	Action string `yaml:"action,omitempty" json:"action,omitempty"`
}

func GenerateCollectorConfigWithSpanMapperProcessor(currentConfYaml []byte, groups []*SpanMapperGroupWithMappers) ([]byte, error) {
	var collectorConf map[string]any
	if err := yaml.Unmarshal(currentConfYaml, &collectorConf); err != nil {
		return nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeInvalidCollectorConfig, "failed to unmarshal collector config")
	}
	// rare but don't do anything in this case, also means it's just comments.
	if collectorConf == nil {
		collectorConf = map[string]any{}
	}

	processors := map[string]any{}
	if existing, ok := collectorConf["processors"]; ok && existing != nil {
		p, ok := existing.(map[string]any)
		if !ok {
			return nil, errors.Newf(errors.TypeInvalidInput, ErrCodeInvalidCollectorConfig, "collector config 'processors' must be a mapping, got %T", existing)
		}
		processors = p
	}

	procConfig := buildProcessorConfig(groups)

	processors[ProcessorName] = procConfig

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Fix YAML syntax (spaces not tabs, valid mapping root)
  2. Pass at least a minimal valid config such as 'service:\n pipelines:' rather than empty bytes if you expect wiring to occur
  3. Run otelcol validate or yamllint on the config before feeding it in

Example fix

// before
conf, err := GenerateCollectorConfigWithSpanMapperProcessor(nil, groups)

// after
base := []byte("receivers:\n  otlp:\n")
conf, err := GenerateCollectorConfigWithSpanMapperProcessor(base, groups)
Defensive patterns

Strategy: validation

Validate before calling

trimmed := bytes.TrimSpace(conf)
if len(trimmed) == 0 { conf = []byte("service:\n") }
var m map[string]any
if err := yaml.Unmarshal(conf, &m); err != nil { /* fix YAML first */ }

Prevention

When it happens

Trigger: Calling RecommendAgentConfig or this function with invalid YAML (tabs, syntax errors, non-mapping root) or with an empty []byte — empty input errors because there is no early return for it in this path.

Common situations: Same hand-edited config issues as other collector-config generators; additionally, callers reusing the LLM-pricing helper's convention of passing empty config get an error here since only comments-only (nil map) is tolerated, not empty bytes.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/0283d0d3a2cf7498. Report an issue: GitHub.