Skip to content

Commit 4a46d6a

Browse files
authored
Remove dangling spaces wherever found. (elastic#127475) (elastic#127611)
* 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 67bd512 commit 4a46d6a

File tree

21 files changed

+48
-29
lines changed

21 files changed

+48
-29
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
@@ -542,7 +542,7 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
542542
+ "This role grants monitor_ml cluster privileges, read access to the .ml-notifications and .ml-anomalies* indices "
543543
+ "(which store machine learning results), and write access to .ml-annotations* indices. "
544544
+ "Machine learning users also need index privileges for source and destination indices "
545-
+ "and roles that grant access to Kibana. "
545+
+ "and roles that grant access to Kibana."
546546
)
547547
),
548548
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
@@ -213,7 +213,7 @@ static DeprecationIssue checkMultipleDataPaths(
213213
"Specifying multiple data paths is deprecated",
214214
"https://ela.st/es-deprecation-7-multiple-paths",
215215
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
216-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ",
216+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.",
217217
false,
218218
null
219219
);
@@ -233,7 +233,7 @@ static DeprecationIssue checkDataPathsList(
233233
"Multiple data paths are not supported",
234234
"https://ela.st/es-deprecation-7-multiple-paths",
235235
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
236-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ",
236+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.",
237237
false,
238238
null
239239
);

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
@@ -112,7 +112,7 @@ public void testMultipleDataPaths() {
112112
issue.getDetails(),
113113
equalTo(
114114
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
115-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. "
115+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0."
116116
)
117117
);
118118
String url = "https://ela.st/es-deprecation-7-multiple-paths";
@@ -137,7 +137,7 @@ public void testDataPathsList() {
137137
issue.getDetails(),
138138
equalTo(
139139
"The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level "
140-
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. "
140+
+ "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0."
141141
)
142142
);
143143
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/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private ElasticsearchStatusException unsupportedStreamingTaskException(Request r
337337
}
338338

339339
private static ElasticsearchStatusException unknownServiceException(String service, String inferenceId) {
340-
return new ElasticsearchStatusException("Unknown service [{}] for model [{}]. ", RestStatus.BAD_REQUEST, service, inferenceId);
340+
return new ElasticsearchStatusException("Unknown service [{}] for model [{}]", RestStatus.BAD_REQUEST, service, inferenceId);
341341
}
342342

343343
private static ElasticsearchStatusException requestModelTaskTypeMismatchException(TaskType requested, TaskType expected) {

0 commit comments

Comments
 (0)