{"record":{"id":"f8a0ab05f068efae","repo":"jaegertracing/jaeger","slug":"invalid-mapping-type-s","errorCode":null,"errorMessage":"invalid mapping type: %s","messagePattern":"invalid mapping type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/elasticsearch/esclient/index_template.go","lineNumber":52,"sourceCode":"\tServiceMapping\n\tDependencyMapping\n\tSamplingMapping\n)\n\n// MappingTypeFromString resolves a Jaeger index base name (e.g. \"jaeger-span\")\n// to its MappingType.\nfunc MappingTypeFromString(name string) (MappingType, error) {\n\tswitch name {\n\tcase config.SpanIndexName:\n\t\treturn SpanMapping, nil\n\tcase config.ServiceIndexName:\n\t\treturn ServiceMapping, nil\n\tcase config.DependencyIndexName:\n\t\treturn DependencyMapping, nil\n\tcase config.SamplingIndexName:\n\t\treturn SamplingMapping, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"invalid mapping type: %s\", name)\n\t}\n}\n\n// file returns the embedded neutral-body file name, or \"\" for an unknown type.\nfunc (m MappingType) file() string {\n\tswitch m {\n\tcase SpanMapping:\n\t\treturn \"jaeger-span.json\"\n\tcase ServiceMapping:\n\t\treturn \"jaeger-service.json\"\n\tcase DependencyMapping:\n\t\treturn \"jaeger-dependencies.json\"\n\tcase SamplingMapping:\n\t\treturn \"jaeger-sampling.json\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/elasticsearch/esclient/index_template.go#L34-L70","documentation":"MappingTypeFromString resolves a Jaeger index base name (e.g. \"jaeger-span\") to a MappingType enum used to render index templates. It returns this error when the name is not one of the four recognized Jaeger index names (span, service, dependencies, sampling). The %s is echoed verbatim so the caller can see which name was rejected.","triggerScenarios":"Calling MappingTypeFromString with a name other than config.SpanIndexName, ServiceIndexName, DependencyIndexName, or SamplingIndexName — e.g. a typo, an index name with a prefix or date suffix attached, or a fully-qualified index name like \"jaeger-span-000001\" instead of the base name.","commonSituations":"Passing the configured index prefix plus name (\"my-prefix-jaeger-span\") instead of the bare base name; passing a rollover physical index name; wiring a custom index name from user config into template generation; iterating over indices returned by GetJaegerIndices (which include dates/rollover numbers) and feeding them to template generation.","solutions":["Pass the bare Jaeger base name (e.g. \"jaeger-span\"), not a prefixed, dated, or rollover-numbered variant","Compare against config.SpanIndexName/ServiceIndexName/DependencyIndexName/SamplingIndexName constants instead of hand-written strings","If handling user input, validate against the four allowed names before calling","If you have a MappingType already, avoid the round-trip: use the enum directly rather than converting from its string form"],"exampleFix":"// before\nmt, err := esclient.MappingTypeFromString(prefix + \"jaeger-span\") // \"my-prefix-jaeger-span\"\n// after\nmt, err := esclient.MappingTypeFromString(config.SpanIndexName) // \"jaeger-span\"","handlingStrategy":"validation","validationCode":"var validNames = map[string]bool{\n    config.SpanIndexName: true, config.ServiceIndexName: true,\n    config.DependencyIndexName: true, config.SamplingIndexName: true,\n}\nif !validNames[name] {\n    return fmt.Errorf(\"unsupported index name %q\", name)\n}\nmt, err := esclient.MappingTypeFromString(name)","typeGuard":"func isJaegerIndexName(name string) bool {\n    switch name {\n    case config.SpanIndexName, config.ServiceIndexName,\n        config.DependencyIndexName, config.SamplingIndexName:\n        return true\n    }\n    return false\n}","tryCatchPattern":"mt, err := esclient.MappingTypeFromString(name)\nif err != nil {\n    return fmt.Errorf(\"cannot render template for %q: %w\", name, err)\n}","preventionTips":["Strip any index prefix and date/rollover suffix before resolving the mapping type","Use the config.*IndexName constants instead of literal strings","Never feed physical index names (from GetJaegerIndices) into template generation","Validate user-configured index names against the four supported bases at config load time"],"tags":["elasticsearch","validation","index-template"],"backgroundTag":"invalid-mapping-type","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}