From 14c4a491d15d5132e623f238d8fed73b5f7b5346 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 11:31:52 -0500 Subject: [PATCH 01/13] Remove dandling spaces wherever found. This PR addresses #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. --- .../org/elasticsearch/xcontent/ObjectParser.java | 2 +- .../ShardsAvailabilityHealthIndicatorService.java | 8 ++++---- .../core/security/CommandLineHttpClient.java | 2 +- .../security/authz/store/ReservedRolesStore.java | 2 +- .../xpack/deprecation/NodeDeprecationChecks.java | 4 ++-- .../expression/function/fulltext/QueryString.java | 2 +- .../action/BaseTransportInferenceAction.java | 2 +- .../action/TransportGetInferenceModelAction.java | 2 +- .../security/cli/HttpCertificateCommand.java | 2 +- .../xpack/security/authc/TokenService.java | 2 +- .../authc/esnative/tool/SetupPasswordTool.java | 4 ++-- .../authc/oidc/OpenIdConnectAuthenticator.java | 2 +- .../security/authc/saml/SamlAuthenticator.java | 2 +- .../security/authz/store/FileRolesStore.java | 4 ++-- .../security/tool/BaseRunAsSuperuserCommand.java | 2 +- .../xpack/sql/proto/content/ObjectParser.java | 2 +- .../action/TransportStopTransformAction.java | 15 +++++++++++++-- 17 files changed, 35 insertions(+), 24 deletions(-) diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java index b28e883476bce..790542498a0c6 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java @@ -334,7 +334,7 @@ private void throwExpectedStartObject(XContentParser parser, XContentParser.Toke private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); + message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified."); } throw new IllegalArgumentException(message.toString()); } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java index 1366d13f71daa..6cfd91e414010 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java @@ -309,7 +309,7 @@ static void updateShardAllocationStatus( NAME, "increase_shard_limit_index_setting", "Elasticsearch isn't allowed to allocate some shards from these indices to any data nodes because each node has reached the index " - + "shard limit. ", + + "shard limit.", "Increase the values for the [" + INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] index setting on each index or add more nodes to the target tiers.", @@ -326,7 +326,7 @@ static void updateShardAllocationStatus( "increase_shard_limit_index_setting:tier:" + tier, "Elasticsearch isn't allowed to allocate some shards from these indices because each node in the [" + tier - + "] tier has reached the index shard limit. ", + + "] tier has reached the index shard limit.", "Increase the values for the [" + INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] index setting on each index or add more nodes to the target tiers.", @@ -357,7 +357,7 @@ static void updateShardAllocationStatus( "increase_shard_limit_cluster_setting:tier:" + tier, "Elasticsearch isn't allowed to allocate some shards from these indices because each node in the [" + tier - + "] tier has reached the cluster shard limit. ", + + "] tier has reached the cluster shard limit.", "Increase the values for the [" + CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] cluster setting or add more nodes to the target tiers.", @@ -405,7 +405,7 @@ static void updateShardAllocationStatus( NAME, "migrate_data_tiers_include_data", "Elasticsearch isn't allowed to allocate some shards from these indices to any nodes in the desired data tiers because the " - + "indices are configured with allocation filter rules that are incompatible with the nodes in this tier. ", + + "indices are configured with allocation filter rules that are incompatible with the nodes in this tier.", "Remove [" + INDEX_ROUTING_INCLUDE_GROUP_PREFIX + ".data] from the index settings or try migrating to data tiers by first stopping ILM [POST /_ilm/stop] and then using " diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java index ada84c98be00b..be0199fc8ba30 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java @@ -277,7 +277,7 @@ public void checkClusterHealthWithRetriesWaitingForCluster(String username, Secu checkClusterHealthWithRetriesWaitingForCluster(username, password, retries); return; } else { - throw new IllegalStateException("Failed to determine the health of the cluster. ", e); + throw new IllegalStateException("Failed to determine the health of the cluster.", e); } } final int responseStatus = response.getHttpStatus(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index 1ec1d5912db68..7251d233e25a9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -496,7 +496,7 @@ private static Map initializeReservedRoles() { + "This role grants monitor_ml cluster privileges, read access to the .ml-notifications and .ml-anomalies* indices " + "(which store machine learning results), and write access to .ml-annotations* indices. " + "Machine learning users also need index privileges for source and destination indices " - + "and roles that grant access to Kibana. " + + "and roles that grant access to Kibana." ) ), entry( diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 7063e189ed3b4..4dcb16135244d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -211,7 +211,7 @@ static DeprecationIssue checkMultipleDataPaths( "Specifying multiple data paths is deprecated", "https://ela.st/es-deprecation-7-multiple-paths", "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ", + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.", false, null ); @@ -231,7 +231,7 @@ static DeprecationIssue checkDataPathsList( "Multiple data paths are not supported", "https://ela.st/es-deprecation-7-multiple-paths", "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ", + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.", false, null ); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java index 79cd7118ae3c5..63a463d1e25a0 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java @@ -145,7 +145,7 @@ public QueryString( name = "allow_wildcard", type = "boolean", valueHint = { "false", "true" }, - description = "If true, the query attempts to analyze wildcard terms in the query string. Defaults to false. " + description = "If true, the query attempts to analyze wildcard terms in the query string. Defaults to false." ), @MapParam.MapParamEntry( name = "analyzer", diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java index 34d2ef0843cfc..dec6d0d928b97 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java @@ -423,7 +423,7 @@ private ElasticsearchStatusException unsupportedStreamingTaskException(Request r } private static ElasticsearchStatusException unknownServiceException(String service, String inferenceId) { - return new ElasticsearchStatusException("Unknown service [{}] for model [{}]. ", RestStatus.BAD_REQUEST, service, inferenceId); + return new ElasticsearchStatusException("Unknown service [{}] for model [{}]", RestStatus.BAD_REQUEST, service, inferenceId); } private static ElasticsearchStatusException requestModelTaskTypeMismatchException(TaskType requested, TaskType expected) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java index 01e663df4a3ea..b7480c092d3a2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java @@ -174,7 +174,7 @@ private void parseModels(List unparsedModels, ActionListener logger.debug( "The Attribute Statements of SAML Response with ID [{}] contained no attributes and the SAML Assertion Subject " + "did not contain a SAML NameID. Please verify that the Identity Provider configuration with regards to attribute " - + "release is correct. ", + + "release is correct.", response.getID() ); throw samlException("Could not process any SAML attributes in {}", response.getElementQName()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java index c1d13e21a246e..e2d56f66cb362 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java @@ -305,7 +305,7 @@ static RoleDescriptor parseRoleDescriptor( Validation.Error validationError = Validation.Roles.validateRoleName(roleName, false); if (validationError != null) { logger.error( - "invalid role definition [{}] in roles file [{}]. invalid role name - {}. skipping role... ", + "invalid role definition [{}] in roles file [{}]. invalid role name - {}. skipping role...", roleName, path.toAbsolutePath(), validationError @@ -392,7 +392,7 @@ private static RoleDescriptor checkDescriptor( Validation.Error validationError = Validation.Roles.validateRoleDescription(descriptor.getDescription()); if (validationError != null) { logger.error( - "invalid role definition [{}] in roles file [{}]. invalid description - {}. skipping role... ", + "invalid role definition [{}] in roles file [{}]. invalid description - {}. skipping role...", roleName, path.toAbsolutePath(), validationError diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java index 542bbbe086cc5..db225540d113d 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java @@ -213,7 +213,7 @@ private void checkClusterHealthWithRetries( try { response = client.execute("GET", clusterHealthUrl, username, password, () -> null, CommandLineHttpClient::responseBuilder); } catch (Exception e) { - throw new UserException(ExitCodes.UNAVAILABLE, "Failed to determine the health of the cluster. ", e); + throw new UserException(ExitCodes.UNAVAILABLE, "Failed to determine the health of the cluster.", e); } final int responseStatus = response.getHttpStatus(); if (responseStatus != HttpURLConnection.HTTP_OK) { diff --git a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java index b3d21193b5915..721d5308c35e8 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java @@ -261,7 +261,7 @@ private void throwFailedToParse(JsonParser parser, String currentFieldName, Exce private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); + message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified."); } throw new ParseException(message.toString()); } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java index 2eb544744856c..a45c1512cba9d 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java @@ -471,24 +471,31 @@ private void waitForTransformStopped( return; } else { StringBuilder message = new StringBuilder(); + boolean lineAdded = false; if (persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Successfully stopped ["); message.append(persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size()); - message.append("] transforms. "); + message.append("] transforms."); + lineAdded = true; } if (exceptions.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Could not stop the transforms "); message.append(exceptions.keySet()); - message.append(" as they were failed. Use force stop to stop the transforms. "); + message.append(" as they were failed. Use force stop to stop the transforms."); + lineAdded = true; } if (stillRunningTasks.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Could not stop the transforms "); message.append(stillRunningTasks); message.append(" as they timed out ["); message.append(timeout.toString()); message.append("]."); + lineAdded = true; } listener.onFailure(new ElasticsearchStatusException(message.toString(), RestStatus.REQUEST_TIMEOUT)); @@ -546,4 +553,8 @@ static ActionListener cancelTransformTasksListener( } }); } + + private static String optionalSpace(boolean spaceNeeded) { + return spaceNeeded ? " " : ""; + } } From 00e3648e70d5989782e4cca96fbef8d3805af8d6 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 11:53:52 -0500 Subject: [PATCH 02/13] fix test --- .../test/java/org/elasticsearch/xcontent/ObjectParserTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java index e4feaa18365f1..60621cbf14357 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java @@ -1004,7 +1004,7 @@ public void testMultipleRequiredFieldSet() throws IOException { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> objectParser.apply(parser, null)); assertThat( e.getMessage(), - equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified. ") + equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified.") ); } From 3efaab8b06e4bd98922144e4acf77eefe76a05ee Mon Sep 17 00:00:00 2001 From: Ankit Sethi <9.ankitsethi@gmail.com> Date: Mon, 28 Apr 2025 13:59:30 -0500 Subject: [PATCH 03/13] Update docs/changelog/127475.yaml --- docs/changelog/127475.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/127475.yaml diff --git a/docs/changelog/127475.yaml b/docs/changelog/127475.yaml new file mode 100644 index 0000000000000..3fd0cf98cfadb --- /dev/null +++ b/docs/changelog/127475.yaml @@ -0,0 +1,5 @@ +pr: 127475 +summary: Remove dangling spaces wherever found +area: Security +type: enhancement +issues: [] From a25baf504e83bf7bf5d514abb83aef4983d9c443 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 14:04:54 -0500 Subject: [PATCH 04/13] correct logic --- .../main/java/org/elasticsearch/xcontent/ObjectParser.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java index 790542498a0c6..a4d66e46f6e2a 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java @@ -334,7 +334,10 @@ private void throwExpectedStartObject(XContentParser parser, XContentParser.Toke private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified."); + message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); + } + if (message.isEmpty() == false) { + message.delete(message.length() - 1, message.length()); } throw new IllegalArgumentException(message.toString()); } From 437a51fab125f3e3237767484dc9375fe10547c2 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 14:19:20 -0500 Subject: [PATCH 05/13] fix test --- .../event/parser/event/AnalyticsEventParserTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java index f989f0e8a8be3..8def025b93aff 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java @@ -84,7 +84,7 @@ public void testParsingWithMissingRequiredField() throws IOException { try (XContentParser xContentParser = createXContentParser(json)) { Exception e = expectThrows(IllegalArgumentException.class, () -> parser().parse(xContentParser, context)); - assertEquals(Strings.format("Required one of fields [%s], but none were specified. ", field), e.getMessage()); + assertEquals(Strings.format("Required one of fields [%s], but none were specified.", field), e.getMessage()); } } } From 5a5a2ade71ccdbb19e4f06ba3a15fb3cab089719 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 14:22:41 -0500 Subject: [PATCH 06/13] fix tests --- .../xpack/deprecation/NodeDeprecationChecksTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 9f2ea63a75166..a63eec596efbe 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -111,7 +111,7 @@ public void testMultipleDataPaths() { issue.getDetails(), equalTo( "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. " + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0." ) ); String url = "https://ela.st/es-deprecation-7-multiple-paths"; @@ -136,7 +136,7 @@ public void testDataPathsList() { issue.getDetails(), equalTo( "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. " + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0." ) ); String url = "https://ela.st/es-deprecation-7-multiple-paths"; From f9abea4ab8cfa8b375db8bd21d86797b94ee6978 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 14:45:59 -0500 Subject: [PATCH 07/13] fix tests --- .../inference/action/BaseTransportInferenceActionTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java index 0edb0763cfd87..f9fafbb92fcc4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java @@ -175,7 +175,7 @@ public void testMetricsAfterMissingService() { verify(listener).onFailure(assertArg(e -> { assertThat(e, isA(ElasticsearchException.class)); - assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "]. ")); + assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "].")); assertThat(((ElasticsearchException) e).status(), is(RestStatus.BAD_REQUEST)); })); verify(inferenceStats.inferenceDuration()).record(anyLong(), assertArg(attributes -> { From 194cf15593d6dc04df11598f458ae5c9fcf98bbc Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Mon, 28 Apr 2025 15:08:25 -0500 Subject: [PATCH 08/13] fix tests --- .../inference/action/BaseTransportInferenceActionTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java index f9fafbb92fcc4..9f08b07ea218d 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceActionTestCase.java @@ -175,7 +175,7 @@ public void testMetricsAfterMissingService() { verify(listener).onFailure(assertArg(e -> { assertThat(e, isA(ElasticsearchException.class)); - assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "].")); + assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "]")); assertThat(((ElasticsearchException) e).status(), is(RestStatus.BAD_REQUEST)); })); verify(inferenceStats.inferenceDuration()).record(anyLong(), assertArg(attributes -> { From 25636a7fe3521976b25a081cc38afe709a6c9d24 Mon Sep 17 00:00:00 2001 From: Ankit Sethi <9.ankitsethi@gmail.com> Date: Tue, 29 Apr 2025 11:29:03 -0500 Subject: [PATCH 09/13] Update docs/changelog/127475.yaml --- docs/changelog/127475.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/127475.yaml b/docs/changelog/127475.yaml index 3fd0cf98cfadb..0398fda30b014 100644 --- a/docs/changelog/127475.yaml +++ b/docs/changelog/127475.yaml @@ -1,5 +1,5 @@ pr: 127475 summary: Remove dangling spaces wherever found area: Security -type: enhancement +type: bug issues: [] From 1b3b6f3fb15e52cc20e7a0eade23dcb456fce9f0 Mon Sep 17 00:00:00 2001 From: Ankit Sethi <9.ankitsethi@gmail.com> Date: Tue, 29 Apr 2025 13:00:49 -0500 Subject: [PATCH 10/13] Update x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slobodan Adamović --- .../inference/action/TransportGetInferenceModelAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java index b7480c092d3a2..0dbbc7715fbfa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java @@ -174,7 +174,7 @@ private void parseModels(List unparsedModels, ActionListener Date: Tue, 29 Apr 2025 13:01:10 -0500 Subject: [PATCH 11/13] Update libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Slobodan Adamović --- .../java/org/elasticsearch/xcontent/ObjectParser.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java index a4d66e46f6e2a..a551515a5261c 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java @@ -333,11 +333,11 @@ private void throwExpectedStartObject(XContentParser parser, XContentParser.Toke private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); - for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); - } - if (message.isEmpty() == false) { - message.delete(message.length() - 1, message.length()); + for (int i = 0; i < requiredFields.size(); i++) { + if (i > 0) { + message.append(" "); + } + message.append("Required one of fields ").append(Arrays.toString(requiredFields.get(i))).append(", but none were specified."); } throw new IllegalArgumentException(message.toString()); } From 859ce47e154d8b005077b444a77018a3fa4ae713 Mon Sep 17 00:00:00 2001 From: ankitsethi Date: Tue, 29 Apr 2025 14:18:58 -0500 Subject: [PATCH 12/13] correctly reference issue --- docs/changelog/127475.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog/127475.yaml b/docs/changelog/127475.yaml index 3fd0cf98cfadb..6e655cee473b2 100644 --- a/docs/changelog/127475.yaml +++ b/docs/changelog/127475.yaml @@ -2,4 +2,5 @@ pr: 127475 summary: Remove dangling spaces wherever found area: Security type: enhancement -issues: [] +issues: + - 117067 From 4778c877a65c6abbdc6a1df67a39ffa97f8d7a65 Mon Sep 17 00:00:00 2001 From: Ankit Sethi <9.ankitsethi@gmail.com> Date: Wed, 30 Apr 2025 13:06:33 -0500 Subject: [PATCH 13/13] Update docs/changelog/127475.yaml --- docs/changelog/127475.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/changelog/127475.yaml b/docs/changelog/127475.yaml index b7f5c44d770ca..0398fda30b014 100644 --- a/docs/changelog/127475.yaml +++ b/docs/changelog/127475.yaml @@ -2,5 +2,4 @@ pr: 127475 summary: Remove dangling spaces wherever found area: Security type: bug -issues: - - 117067 +issues: []