Skip to content

Commit c85ce02

Browse files
authored
Always show composed_of field for composable index templates (#105315) (#105571)
* Always show `composed_of` field for composable index templates Prior to e786cfa we inadvertently always added composable index templates with `composed_of: []` beacuse e786cfa#diff-5081302eb39033199deb1977d544d1cd7867212a92b8d77e0aa0ded361272b11L618-L630 created a new `ComposableIndexTemplate` from an existing one, and the `.composedOf()` field returned an empty list of no component templates were provided: https://github.com/elastic/elasticsearch/blob/89e714ee5dc60db8b4979ab6372ff767e108e9da/server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java#L172-L177 This meant that before 8.12.0 we would always show `composed_of: []` for composable index templates. This commit recreates this behavior, and always displays the empty list even if no component templates are used by a composable index template. Resolves #104627
1 parent 4d229ee commit c85ce02

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

docs/changelog/105315.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 105315
2+
summary: Always show `composed_of` field for composable index templates
3+
area: Indices APIs
4+
type: bug
5+
issues:
6+
- 104627

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.get_index_template/10_basic.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,16 @@ setup:
188188
type: keyword
189189
lifecycle:
190190
data_retention: "30d"
191+
192+
---
193+
"Get index template always shows composed_of":
194+
- skip:
195+
version: " - 8.12.99"
196+
reason: "A bug was fixed in 8.13.0 to make `composed_of` always returned"
197+
198+
- do:
199+
indices.get_index_template:
200+
name: test
201+
202+
- match: {index_templates.0.name: test}
203+
- match: {index_templates.0.index_template.composed_of: []}

server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private ComposableIndexTemplate(
125125
) {
126126
this.indexPatterns = indexPatterns;
127127
this.template = template;
128-
this.componentTemplates = componentTemplates;
128+
this.componentTemplates = componentTemplates == null ? List.of() : componentTemplates;
129129
this.priority = priority;
130130
this.version = version;
131131
this.metadata = metadata;

0 commit comments

Comments
 (0)