{"record":{"id":"cf99e7f64ce96db6","repo":"jaegertracing/jaeger","slug":"error-generating-mappings-w","errorCode":null,"errorMessage":"error generating mappings: %w","messagePattern":"error generating mappings: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/elasticsearch/mappings/command.go","lineNumber":25,"sourceCode":"\t\"fmt\"\n\t\"strconv\"\n\n\t\"github.com/spf13/cobra\"\n\n\t\"github.com/jaegertracing/jaeger/internal/storage/elasticsearch/config\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/elasticsearch/esclient\"\n)\n\nfunc Command() *cobra.Command {\n\toptions := Options{}\n\tcommand := &cobra.Command{\n\t\tUse:   \"elasticsearch-mappings\",\n\t\tShort: \"Jaeger esmapping-generator prints rendered mappings as string\",\n\t\tLong:  \"Jaeger esmapping-generator renders passed templates with provided values and prints rendered output to stdout\",\n\t\tRunE: func(_ *cobra.Command, _ /* args */ []string) error {\n\t\t\tresult, err := generateMappings(options)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error generating mappings: %w\", err)\n\t\t\t}\n\t\t\tfmt.Println(result)\n\t\t\treturn nil\n\t\t},\n\t}\n\toptions.AddFlags(command)\n\n\treturn command\n}\n\n// generateMappings renders the index template for the requested mapping type and\n// backend version. It is an offline generator, so it renders through\n// esclient.RenderIndexTemplate for an explicitly-passed version rather than a\n// version resolved from a live cluster.\nfunc generateMappings(options Options) (string, error) {\n\tmappingType, err := esclient.MappingTypeFromString(options.Mapping)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid mapping type %q: please pass one of %q, %q, %q, or %q as the mapping type\", options.Mapping, config.SpanIndexName, config.ServiceIndexName, config.DependencyIndexName, config.SamplingIndexName)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/elasticsearch/mappings/command.go#L7-L43","documentation":"The elasticsearch-mappings cobra command (esmapping-generator) runs generateMappings and wraps any error it returns as \"error generating mappings\" before exiting. generateMappings validates the mapping type, parses the ILM flag, and renders the index template; any failure in those steps surfaces through this wrapper. The process prints nothing to stdout and cobra reports the wrapped error.","triggerScenarios":"Running the esmapping-generator with an invalid --mapping type (not spans/services/dependencies/sampling), a --use-ilm flag that is not a valid bool, or a version/template combination that makes RenderIndexTemplate fail (e.g. unsupported --es-version).","commonSituations":"CI scripts invoking esmapping-generator with typo'd flags; upgrading Jaeger where the accepted mapping-type names changed; passing ILM options like \"yes\"/\"1\" variants strconv.ParseBool rejects (only 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False accepted); an --es-version the renderer cannot handle.","solutions":["Read the inner (%w) error: it says whether the mapping type, the ILM bool, or the template rendering failed.","Fix --mapping to one of spans, services, dependencies, or sampling.","Fix --use-ilm to a strconv.ParseBool-accepted value: true/false (or 1/0, t/f, TRUE/FALSE, etc.).","If rendering fails, check --es-version and ILM policy name are supported by the installed Jaeger version; upgrade or adjust flags accordingly."],"exampleFix":"// before\nesmapping-generator --mapping span --use-ilm yes\n// after\nesmapping-generator --mapping spans --use-ilm true","handlingStrategy":"validation","validationCode":"validMappings := map[string]bool{\"spans\": true, \"services\": true, \"dependencies\": true, \"sampling\": true}\nif !validMappings[options.Mapping] {\n\treturn fmt.Errorf(\"--mapping must be one of spans, services, dependencies, sampling\")\n}\nif _, err := strconv.ParseBool(options.UseILM); err != nil {\n\treturn fmt.Errorf(\"--use-ilm must be a boolean (true/false)\")\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"esmapping-generator\", \"--mapping\", \"spans\", \"--use-ilm\", \"true\").Output()\nif err != nil {\n\tvar ee *exec.ExitError\n\tif errors.As(err, &ee) {\n\t\tlog.Fatalf(\"esmapping-generator failed: %s\", ee.Stderr) // contains the wrapped cause\n\t}\n\treturn err\n}","preventionTips":["Use exact mapping-type names: spans, services, dependencies, sampling.","Pass --use-ilm strictly as true or false (strconv.ParseBool-compatible).","Test the generator command locally with the same flags used in CI before deploying index-init jobs.","Check the Jaeger docs for the --es-version values your release supports before rendering templates."],"tags":["cli","config","template-rendering","elasticsearch"],"backgroundTag":"mapping-generation-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}