{"record":{"id":"3bf0573f94bb0e3f","repo":"jaegertracing/jaeger","slug":"failed-to-render-mapping-to-string-w","errorCode":null,"errorMessage":"failed to render mapping to string: %w","messagePattern":"failed to render mapping to string: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/elasticsearch/mappings/command.go","lineNumber":62,"sourceCode":"\t}\n\tenableILM, err := strconv.ParseBool(options.UseILM)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tindexOpts := config.IndexOptions{\n\t\tShards:   options.Shards,\n\t\tReplicas: options.Replicas,\n\t}\n\tindices := config.Indices{\n\t\tIndexPrefix:  config.IndexPrefix(options.IndexPrefix),\n\t\tSpans:        indexOpts,\n\t\tServices:     indexOpts,\n\t\tDependencies: indexOpts,\n\t\tSampling:     indexOpts,\n\t}\n\trendered, err := esclient.RenderIndexTemplate(mappingType, indices, enableILM, options.ILMPolicyName, options.Version)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to render mapping to string: %w\", err)\n\t}\n\treturn rendered, nil\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/elasticsearch/mappings/command.go#L44-L66","documentation":"After the mapping type is resolved, generateMappings renders the index template offline via esclient.RenderIndexTemplate for the explicitly passed --version. If that rendering fails (unsupported version, ILM policy serialization problem, etc.) the underlying error is wrapped with this message so the CLI reports which stage failed.","triggerScenarios":"Calling generateMappings with an options.Version that RenderIndexTemplate cannot render a template for, or an ILMPolicyName/enableILM combination the renderer rejects; RenderIndexTemplate returns a non-nil error.","commonSituations":"Passing an --es-version outside 7/8/9 (or OpenSearch 101-103); template rendering code updated while pinned flags were not; corrupted or empty policy name with --use-ilm=true.","solutions":["Read the wrapped %w cause in the error output; it identifies the renderer failure (usually unsupported version).","Pass a supported version via --backend or --es-version (7, 8, 9, or OpenSearch 101-103).","If using ILM, ensure --ilm-policy-name names a valid policy and the embedded policy JSON renders for that version."],"exampleFix":"// before\n--es-version=6\n// after\n--backend=elasticsearch --es-version=7","handlingStrategy":"try-catch","validationCode":"if !es.IsSupportedVersion(uint(options.Version)) {\n  return fmt.Errorf(\"version %d not renderable; use 7/8/9 or 101/102/103\", options.Version)\n}","typeGuard":null,"tryCatchPattern":"rendered, err := generateMappings(options)\nif err != nil {\n  return fmt.Errorf(\"mapping generation failed: %w\", err)\n}","preventionTips":["Always pass a supported backend version (7/8/9 or OpenSearch 101-103).","Prefer --backend over --es-version so the version is resolved consistently.","Test the mapping command in CI against the same ES/OpenSearch major version used in production."],"tags":["elasticsearch","template-rendering","versioning"],"backgroundTag":"unsupported-version","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}