-
Notifications
You must be signed in to change notification settings - Fork 141
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
Rework on error reporting to make it more verbose and human-friendly. #839
Rework on error reporting to make it more verbose and human-friendly. #839
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #839 +/- ##
============================================
- Coverage 97.58% 94.95% -2.63%
- Complexity 3162 3190 +28
============================================
Files 305 316 +11
Lines 7902 8646 +744
Branches 515 637 +122
============================================
+ Hits 7711 8210 +499
- Misses 190 382 +192
- Partials 1 54 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -70,8 +70,12 @@ public void sqlDeleteSettingsTest() throws IOException { | |||
"{\n" | |||
+ " \"error\": {\n" | |||
+ " \"reason\": \"Invalid SQL query\",\n" | |||
+ " \"details\": \"DELETE clause is disabled by default and will be deprecated. Using " | |||
+ "the plugins.sql.delete.enabled setting to enable it\",\n" | |||
+ " \"details\": \"" |
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.
comparing old one, the message is more confuse for customer.
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.
docs/user/admin/settings.rst
Outdated
@@ -305,7 +305,7 @@ SQL query:: | |||
{ | |||
"error": { | |||
"reason": "Invalid SQL query", | |||
"details": "DELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it", | |||
"details": "Failed to parse query due to offending symbol [DELETE] at: 'DELETE' <--- HERE... More details: Expecting tokens in {<EOF>, 'DESCRIBE', 'SELECT', 'SHOW', ';'}\nQuery failed on both V1 and V2 SQL engines. V1 SQL engine error following: \nDELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it", |
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.
any reason we want to expose V1/V2 engine info for customer?
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.
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.
as discussed, we may want to simplify error message exposed to customer and log this kind of detailed message for our developer use.
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.
Fixed in de104bf.
common/src/main/java/org/opensearch/sql/common/utils/QueryContext.java
Outdated
Show resolved
Hide resolved
legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSqlAction.java
Outdated
Show resolved
Hide resolved
03b0bcb
to
bb91d5a
Compare
Rebased to resolve conflicts. |
@@ -0,0 +1,209 @@ | |||
package org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance; |
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.
missing license header. any reason why there are a lot of relevance related changes in this PR?
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.
Thank you, fixed in a0f9970.
I updated all relevance functions to use this FunctionParameterRepository
to validate functions' arguments' values and generate user-friendly error messages.
I also updated base RelevanceQuery
class to do better argument check.
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 wondering did Github action fail on missing license header?
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.
We don't have such validation yet.
docs/user/admin/settings.rst
Outdated
@@ -305,7 +305,7 @@ SQL query:: | |||
{ | |||
"error": { | |||
"reason": "Invalid SQL query", | |||
"details": "DELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it", | |||
"details": "Failed to parse query due to offending symbol [DELETE] at: 'DELETE' <--- HERE... More details: Expecting tokens in {<EOF>, 'DESCRIBE', 'SELECT', 'SHOW', ';'}", |
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.
I think the originl message is much clear
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.
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.
Revered in b5ad3c9.
* Can be deleted once the | ||
* legacy SQL engine is deprecated. | ||
*/ | ||
public static void setError(String error) { |
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.
do we have better way to pass error messsage around instead of using threadcontext? we should consider deprecated threadcontext instead of add more capability to it.
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 feature (aggregating error messages from V1 and V2) will be removed soon along with V1. I can create/use a thread-safe singleton Map instead.
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.
Revered in b5ad3c9.
var field = arguments.stream() | ||
.filter(a -> a.getArgName().equalsIgnoreCase("field")) | ||
.findFirst() | ||
.orElse(null); | ||
var fields = arguments.stream() | ||
.filter(a -> a.getArgName().equalsIgnoreCase("fields")) | ||
.findFirst() | ||
.orElse(null); | ||
if (fields == null && field == null) { | ||
throw new SemanticCheckException("Both 'field' and 'fields' parameters are missing."); | ||
} | ||
if (fields != null && field != null) { | ||
throw new SemanticCheckException("Both 'field' and 'fields' parameters are given."); | ||
} | ||
|
||
var query = arguments.stream() | ||
.filter(a -> a.getArgName().equalsIgnoreCase("query")) | ||
.findFirst() | ||
.orElseThrow(() -> new SemanticCheckException("'query' parameter is missing")); | ||
T queryBuilder = createQueryBuilder((field != null ? field : fields), query); |
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.
Code specific to single field functions belongs in SingleFieldQuery
class, multi-field functions -- MultiFieldQuery
.
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.
Thank you, fixed in 2f1e302.
Notes:
- we can't check whether
field
andfields
present both query
check could be moved to a separate method to the superclass, but the benefit is rather low
What about to move all |
Updated in 827a0cf. |
…#116) Co-authored-by: MaxKsyunz <[email protected]> Co-authored-by: forestmvey <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
827a0cf
to
89b3e1a
Compare
Rebased to resolve conflicts. |
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.
Thanks for the change!
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.4 2.4
# Navigate to the new working tree
cd .worktrees/backport-2.4
# Create a new branch
git switch --create backport/backport-839-to-2.4
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 21373b9380dea321063dc6a5532b84a2ebec32a4
# Push it to GitHub
git push --set-upstream origin backport/backport-839-to-2.4
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.4 Then, create a pull request where the |
…e-error-reporting Rework on error reporting to make it more verbose and human-friendly. (cherry picked from commit 21373b9) Signed-off-by: Yury-Fridlyand <[email protected]>
…1008) Rework on error reporting to make it more verbose and human-friendly. (cherry picked from commit 21373b9) Signed-off-by: Yury-Fridlyand <[email protected]>
Rework on #691
Co-authored-by: MaxKsyunz [email protected]
Co-authored-by: forestmvey [email protected]
Signed-off-by: Yury-Fridlyand [email protected]
Description
1.
Added cast validation and user-friendly error messages
before
after
2.
Cast validation and user-friendly errors for all enum types
before
after
3.
Extended error message when incorrect parameters specified
before
after
4.
Error aggregation fromRevertedV1
andV2
enginesIssues Resolved
#838
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.