{"record":{"id":"0283d0d3a2cf7498","repo":"SigNoz/signoz","slug":"errcodeinvalidcollectorconfig-0283d0","errorCode":"ErrCodeInvalidCollectorConfig","errorMessage":"failed to unmarshal collector config","messagePattern":"failed to unmarshal collector config","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/types/spantypes/spanmapperprocessor.go","lineNumber":57,"sourceCode":"\tAttributes []string `yaml:\"attributes,omitempty\" json:\"attributes,omitempty\"`\n\tResource   []string `yaml:\"resource,omitempty\" json:\"resource,omitempty\"`\n}\n\ntype spanMapperProcessorAttribute struct {\n\tTarget  string                      `yaml:\"target\" json:\"target\"`\n\tContext string                      `yaml:\"context,omitempty\" json:\"context,omitempty\"`\n\tSources []spanMapperProcessorSource `yaml:\"sources\" json:\"sources\"`\n}\n\ntype spanMapperProcessorSource struct {\n\tKey    string `yaml:\"key\" json:\"key\"`\n\tAction string `yaml:\"action,omitempty\" json:\"action,omitempty\"`\n}\n\nfunc GenerateCollectorConfigWithSpanMapperProcessor(currentConfYaml []byte, groups []*SpanMapperGroupWithMappers) ([]byte, error) {\n\tvar collectorConf map[string]any\n\tif err := yaml.Unmarshal(currentConfYaml, &collectorConf); err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeInvalidCollectorConfig, \"failed to unmarshal collector config\")\n\t}\n\t// rare but don't do anything in this case, also means it's just comments.\n\tif collectorConf == nil {\n\t\tcollectorConf = map[string]any{}\n\t}\n\n\tprocessors := map[string]any{}\n\tif existing, ok := collectorConf[\"processors\"]; ok && existing != nil {\n\t\tp, ok := existing.(map[string]any)\n\t\tif !ok {\n\t\t\treturn nil, errors.Newf(errors.TypeInvalidInput, ErrCodeInvalidCollectorConfig, \"collector config 'processors' must be a mapping, got %T\", existing)\n\t\t}\n\t\tprocessors = p\n\t}\n\n\tprocConfig := buildProcessorConfig(groups)\n\n\tprocessors[ProcessorName] = procConfig","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/spantypes/spanmapperprocessor.go#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix YAML syntax (spaces not tabs, valid mapping root)","Pass at least a minimal valid config such as 'service:\\n  pipelines:' rather than empty bytes if you expect wiring to occur","Run otelcol validate or yamllint on the config before feeding it in"],"exampleFix":"// before\nconf, err := GenerateCollectorConfigWithSpanMapperProcessor(nil, groups)\n\n// after\nbase := []byte(\"receivers:\\n  otlp:\\n\")\nconf, err := GenerateCollectorConfigWithSpanMapperProcessor(base, groups)","handlingStrategy":"validation","validationCode":"trimmed := bytes.TrimSpace(conf)\nif len(trimmed) == 0 { conf = []byte(\"service:\\n\") }\nvar m map[string]any\nif err := yaml.Unmarshal(conf, &m); err != nil { /* fix YAML first */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember this generator rejects empty bytes unlike the LLM-pricing variant","Always supply a minimal valid base config"],"tags":["yaml","otel-collector","span-mapper","config"],"backgroundTag":"invalid-yaml-config","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}