-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ML] Perform query field validation for rerank task type #137219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Perform query field validation for rerank task type #137219
Conversation
|
Hi @jonathan-buttner, I've created a changelog YAML for you. |
|
Pinging @elastic/ml-core (Team:ML) |
DonalEvans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of minor points, not mandatory
| String responseJson = """ | ||
| { | ||
| "index": "d0760819-5a73-4d58-b163-3956d3648b62", | ||
| "results": [ | ||
| ], | ||
| "meta": { | ||
| "api_version": { | ||
| "version": "1" | ||
| }, | ||
| "billed_units": { | ||
| "search_units": 1 | ||
| } | ||
| } | ||
| } | ||
| """; | ||
| webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary, since the test never actually tries to get a response, as it fails in validation before sending the request.
| MatcherAssert.assertThat(result.asMap(), Matchers.is(buildExpectationRerank(List.of()))); | ||
| MatcherAssert.assertThat(webServer.requests(), hasSize(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but this class uses MatcherAssert.assertThat() in a lot of places instead of using ESTestCase.assertThat() (even though they're the same under the hood). Would it improve consistency to do a quick find/replace to remove the MatcherAssert. and have all assertions using the same assertThat() method?
…buttner/elasticsearch into ml-fix-rerank-query-validation
) * Validating that query is defined for rerank task * Validation for completion works without query field * Update docs/changelog/137219.yaml * Addressing feedback * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co> (cherry picked from commit 34145ed) # Conflicts: # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
…) (#137292) * Fixing merge error * Fixing import
…) (#137293) * [ML] Perform query field validation for rerank task type (#137219) * Validating that query is defined for rerank task * Validation for completion works without query field * Update docs/changelog/137219.yaml * Addressing feedback * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co> (cherry picked from commit 34145ed) # Conflicts: # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java * Fixing tests
) (#137294) * [ML] Perform query field validation for rerank task type (#137219) * Validating that query is defined for rerank task * Validation for completion works without query field * Update docs/changelog/137219.yaml * Addressing feedback * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co> (cherry picked from commit 34145ed) # Conflicts: # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java * Fixing merge error * fixing test
Fixes an issue where if a request did not include the task type in the URL, and the
queryfield was not included in the request, a null pointer would be thrown.This PR will have a validation exception be thrown indicating that the query field must be defined for the rerank task type.
Testing
Create inference endpoint
Issue request without task type in URL
That should return with a validation error.