Skip to content

Commit a699e97

Browse files
authored
[9.0] [Deprecation API] Adjust details in the SourceFieldMapper deprecation warning (#122041) (#122068)
* [Deprecation API] Adjust details in the SourceFieldMapper deprecation warning (#122041) In this PR we improve the deprecation warning about configuring source in the mapping. - We reduce the size of the warning message so it looks better in kibana. - We keep the original message in the details. - We use an alias help url, so we can associate it with the guide when it's created. * Remove bwc code
1 parent 1b92499 commit a699e97

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ private void assertDeprecationWarningForTemplate(String templateName) throws IOE
8585
assertThat(response.containsKey("templates"), equalTo(true));
8686
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
8787
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
88-
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
89-
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
88+
var templateIssue = (Map<?, ?>) ((List<?>) issuesByTemplate.get(templateName)).getFirst();
89+
assertThat(templateIssue.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING_TITLE));
90+
assertThat(templateIssue.get("details"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
9091
}
9192
}

server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class SourceFieldMapper extends MetadataFieldMapper {
5858

5959
public static final String LOSSY_PARAMETERS_ALLOWED_SETTING_NAME = "index.lossy.source-mapping-parameters";
6060

61+
public static final String DEPRECATION_WARNING_TITLE = "Configuring source mode in mappings is deprecated.";
62+
6163
public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated and will be removed "
6264
+ "in future versions. Use [index.mapping.source.mode] index setting instead.";
6365

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ private DeprecationIssue checkSourceModeInComponentTemplates(ComponentTemplate t
122122
if (sourceMap.containsKey("mode")) {
123123
return new DeprecationIssue(
124124
DeprecationIssue.Level.CRITICAL,
125+
SourceFieldMapper.DEPRECATION_WARNING_TITLE,
126+
"https://ela.st/migrate-source-mode",
125127
SourceFieldMapper.DEPRECATION_WARNING,
126-
"https://github.com/elastic/elasticsearch/pull/117172",
127-
null,
128128
false,
129129
null
130130
);

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public void testCheckSourceModeInComponentTemplates() throws IOException {
5151
Map<String, List<DeprecationIssue>> issuesByComponentTemplate = checker.check(clusterState);
5252
final DeprecationIssue expected = new DeprecationIssue(
5353
DeprecationIssue.Level.CRITICAL,
54+
SourceFieldMapper.DEPRECATION_WARNING_TITLE,
55+
"https://ela.st/migrate-source-mode",
5456
SourceFieldMapper.DEPRECATION_WARNING,
55-
"https://github.com/elastic/elasticsearch/pull/117172",
56-
null,
5757
false,
5858
null
5959
);

0 commit comments

Comments
 (0)