Skip to content

Commit 476a31d

Browse files
authored
Remove dangling spaces wherever found. (elastic#127475) (elastic#127607)
* Remove dandling spaces wherever found. This PR addresses elastic#117067 , a report about unexpected spaces breaking message parsers built by customers. I used the regex `(\. \")(?![A-Z(a-z_0-9-;<%\/\.+ \t\n]+)` to detect such instances and clean up. In one case, a minor code improvement helps add optional spaces as necessary for a multi-sentence error message. * fix test * Update docs/changelog/127475.yaml * correct logic * fix test * fix tests * fix tests * fix tests * Update docs/changelog/127475.yaml * Update x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java Co-authored-by: Slobodan Adamović <[email protected]> * Update libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java Co-authored-by: Slobodan Adamović <[email protected]> * correctly reference issue * Update docs/changelog/127475.yaml --------- Co-authored-by: Slobodan Adamović <[email protected]> (cherry picked from commit 94854b3)
1 parent 1965d6c commit 476a31d

File tree

22 files changed

+49
-30
lines changed

22 files changed

+49
-30
lines changed

docs/changelog/127475.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127475
2+
summary: Remove dangling spaces wherever found
3+
area: Security
4+
type: bug
5+
issues: []

libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ private void throwExpectedStartObject(XContentParser parser, XContentParser.Toke
333333

334334
private static void throwMissingRequiredFields(List<String[]> requiredFields) {
335335
final StringBuilder message = new StringBuilder();
336-
for (String[] fields : requiredFields) {
337-
message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. ");
336+
for (int i = 0; i < requiredFields.size(); i++) {
337+
if (i > 0) {
338+
message.append(" ");
339+
}
340+
message.append("Required one of fields ").append(Arrays.toString(requiredFields.get(i))).append(", but none were specified.");
338341
}
339342
throw new IllegalArgumentException(message.toString());
340343
}

libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ public void testMultipleRequiredFieldSet() throws IOException {
10041004
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> objectParser.apply(parser, null));
10051005
assertThat(
10061006
e.getMessage(),
1007-
equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified. ")
1007+
equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified.")
10081008
);
10091009
}
10101010

server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static void updateShardAllocationStatus(
299299
NAME,
300300
"increase_shard_limit_index_setting",
301301
"Elasticsearch isn't allowed to allocate some shards from these indices to any data nodes because each node has reached the index "
302-
+ "shard limit. ",
302+
+ "shard limit.",
303303
"Increase the values for the ["
304304
+ INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey()
305305
+ "] index setting on each index or add more nodes to the target tiers.",
@@ -316,7 +316,7 @@ static void updateShardAllocationStatus(
316316
"increase_shard_limit_index_setting:tier:" + tier,
317317
"Elasticsearch isn't allowed to allocate some shards from these indices because each node in the ["
318318
+ tier
319-
+ "] tier has reached the index shard limit. ",
319+
+ "] tier has reached the index shard limit.",
320320
"Increase the values for the ["
321321
+ INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey()
322322
+ "] index setting on each index or add more nodes to the target tiers.",
@@ -347,7 +347,7 @@ static void updateShardAllocationStatus(
347347
"increase_shard_limit_cluster_setting:tier:" + tier,
348348
"Elasticsearch isn't allowed to allocate some shards from these indices because each node in the ["
349349
+ tier
350-
+ "] tier has reached the cluster shard limit. ",
350+
+ "] tier has reached the cluster shard limit.",
351351
"Increase the values for the ["
352352
+ CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey()
353353
+ "] cluster setting or add more nodes to the target tiers.",
@@ -395,7 +395,7 @@ static void updateShardAllocationStatus(
395395
NAME,
396396
"migrate_data_tiers_include_data",
397397
"Elasticsearch isn't allowed to allocate some shards from these indices to any nodes in the desired data tiers because the "
398-
+ "indices are configured with allocation filter rules that are incompatible with the nodes in this tier. ",
398+
+ "indices are configured with allocation filter rules that are incompatible with the nodes in this tier.",
399399
"Remove ["
400400
+ INDEX_ROUTING_INCLUDE_GROUP_PREFIX
401401
+ ".data] from the index settings or try migrating to data tiers by first stopping ILM [POST /_ilm/stop] and then using "

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public void checkClusterHealthWithRetriesWaitingForCluster(String username, Secu
277277
checkClusterHealthWithRetriesWaitingForCluster(username, password, retries);
278278
return;
279279
} else {
280-
throw new IllegalStateException("Failed to determine the health of the cluster. ", e);
280+
throw new IllegalStateException("Failed to determine the health of the cluster.", e);
281281
}
282282
}
283283
final int responseStatus = response.getHttpStatus();

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
494494
+ "This role grants monitor_ml cluster privileges, read access to the .ml-notifications and .ml-anomalies* indices "
495495
+ "(which store machine learning results), and write access to .ml-annotations* indices. "
496496
+ "Machine learning users also need index privileges for source and destination indices "
497-
+ "and roles that grant access to Kibana. "
497+
+ "and roles that grant access to Kibana."
498498
)
499499
),
500500
entry(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static DeprecationIssue checkMultipleDataPaths(
211211
"Specifying multiple data paths is deprecated",
212212
"https://ela.st/es-deprecation-7-multiple-paths",
213213
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
214-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ",
214+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.",
215215
false,
216216
null
217217
);
@@ -231,7 +231,7 @@ static DeprecationIssue checkDataPathsList(
231231
"Multiple data paths are not supported",
232232
"https://ela.st/es-deprecation-7-multiple-paths",
233233
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
234-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ",
234+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.",
235235
false,
236236
null
237237
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void testMultipleDataPaths() {
111111
issue.getDetails(),
112112
equalTo(
113113
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
114-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. "
114+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0."
115115
)
116116
);
117117
String url = "https://ela.st/es-deprecation-7-multiple-paths";
@@ -136,7 +136,7 @@ public void testDataPathsList() {
136136
issue.getDetails(),
137137
equalTo(
138138
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
139-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. "
139+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0."
140140
)
141141
);
142142
String url = "https://ela.st/es-deprecation-7-multiple-paths";

x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testParsingWithMissingRequiredField() throws IOException {
8484

8585
try (XContentParser xContentParser = createXContentParser(json)) {
8686
Exception e = expectThrows(IllegalArgumentException.class, () -> parser().parse(xContentParser, context));
87-
assertEquals(Strings.format("Required one of fields [%s], but none were specified. ", field), e.getMessage());
87+
assertEquals(Strings.format("Required one of fields [%s], but none were specified.", field), e.getMessage());
8888
}
8989
}
9090
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public QueryString(
152152
name = "allow_wildcard",
153153
type = "boolean",
154154
valueHint = { "false", "true" },
155-
description = "If true, the query attempts to analyze wildcard terms in the query string. Defaults to false. "
155+
description = "If true, the query attempts to analyze wildcard terms in the query string. Defaults to false."
156156
),
157157
@MapParam.MapParamEntry(
158158
name = "analyzer",

0 commit comments

Comments
 (0)