[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.
This commit is contained in:
Mary Gouseti 2025-02-07 19:55:14 +02:00 committed by GitHub
parent 3ed5f73600
commit 1fe1055aef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 6 deletions

View file

@ -85,7 +85,13 @@ public class SourceModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
assertThat(response.containsKey("templates"), equalTo(true));
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
var templateIssue = (Map<?, ?>) ((List<?>) issuesByTemplate.get(templateName)).getFirst();
// Bwc compatible logic until backports are complete.
if (templateIssue.containsKey("details")) {
assertThat(templateIssue.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING_TITLE));
assertThat(templateIssue.get("details"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
} else {
assertThat(templateIssue.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
}
}
}

View file

@ -58,6 +58,8 @@ public class SourceFieldMapper extends MetadataFieldMapper {
public static final String LOSSY_PARAMETERS_ALLOWED_SETTING_NAME = "index.lossy.source-mapping-parameters";
public static final String DEPRECATION_WARNING_TITLE = "Configuring source mode in mappings is deprecated.";
public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated and will be removed "
+ "in future versions. Use [index.mapping.source.mode] index setting instead.";

View file

@ -122,9 +122,9 @@ public class TemplateDeprecationChecker implements ResourceDeprecationChecker {
if (sourceMap.containsKey("mode")) {
return new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
SourceFieldMapper.DEPRECATION_WARNING_TITLE,
"https://ela.st/migrate-source-mode",
SourceFieldMapper.DEPRECATION_WARNING,
"https://github.com/elastic/elasticsearch/pull/117172",
null,
false,
null
);

View file

@ -51,9 +51,9 @@ public class TemplateDeprecationCheckerTests extends ESTestCase {
Map<String, List<DeprecationIssue>> issuesByComponentTemplate = checker.check(clusterState);
final DeprecationIssue expected = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
SourceFieldMapper.DEPRECATION_WARNING_TITLE,
"https://ela.st/migrate-source-mode",
SourceFieldMapper.DEPRECATION_WARNING,
"https://github.com/elastic/elasticsearch/pull/117172",
null,
false,
null
);