-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix painless casting bug causing opensearch to crash #8315
Conversation
Gradle Check (Jenkins) Run Completed with:
|
So this is a new feature? I don't know this code well, what does this do? What are the downsides? If it's new, you should make a PR adding the feature first, then another one that fixes the bug we're talking about on top, just to keep things clean. |
Gradle Check (Jenkins) Run Completed with:
|
This change would allow users to run painless scripts with update context. Although, it is not my intention to add this as a new feature. Rather than creating a new feature, I wanted to keep context which is only used in tests and not by customers.
This API allows customers to execute painless scripts with are not stored. Providing an Update context script has no major use case here. |
@shiv0408 could you please clarify what is supposed outcome of this script (from the issue):
[1] https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#update-api-example |
@reta I was modifying some script to reproduce the issue. The purpose of this script is just to demonstrate the issue, so did not use |
And I am calling this update context, but any void context like |
So if the context is void expected - why script should return anything? And what is happening with the results that script returns? (as I see here, we just drop it) |
Signed-off-by: Shivansh Arora <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
Thanks for approval @reta. Added DCO on all commits. |
@dblock looks good to you? |
Gradle Check (Jenkins) Run Completed with:
|
@reta Can we try to get this merged before 2.9 branch cut? |
modules/lang-painless/src/test/java/org/opensearch/painless/FactoryTests.java
Show resolved
Hide resolved
Signed-off-by: Shivansh Arora <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #8315 +/- ##
============================================
+ Coverage 70.77% 71.30% +0.52%
- Complexity 56893 57300 +407
============================================
Files 4758 4758
Lines 269417 269417
Branches 39420 39420
============================================
+ Hits 190679 192095 +1416
+ Misses 62635 61479 -1156
+ Partials 16103 15843 -260
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
@dblock I think it should be good to merge now. |
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.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-8315-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a39f60f482c405a102e6eec83097e91acc90a889
# Push it to GitHub
git push --set-upstream origin backport/backport-8315-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x Then, create a pull request where the |
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]> (cherry picked from commit a39f60f)
* Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]> (cherry picked from commit a39f60f)
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]>
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]>
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]>
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]> Signed-off-by: sahil buddharaju <[email protected]>
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]>
…ect#8315) * Created a failing test to reproduce painless bug Signed-off-by: Shivansh Arora <[email protected]> * Removed unused import Signed-off-by: Shivansh Arora <[email protected]> * Throw exception when trying to cast def to void Signed-off-by: Shivansh Arora <[email protected]> * Removed update context change Signed-off-by: Shivansh Arora <[email protected]> * Created a different test Signed-off-by: Shivansh Arora <[email protected]> --------- Signed-off-by: Shivansh Arora <[email protected]> Signed-off-by: Shivansh Arora <[email protected]>
Description
Update
Throwing ClassCastException when trying to cast def to void.
Created a Unit Test to ensure that def to void casting throws ClassCastException. Removed the following mention Unit Test as it was just added to reproduce the issue. The current unit test should be enough to avoid any regression in future.
Created a unit test to reproduce the bug #6435 by creating a unit test. Fix for this is requires a small change in
modules/lang-painless/src/main/java/org/opensearch/painless/AnalyzerCaster.java
to throwClassCastException
when we are trying to castdef
tovoid
. But to create this unit test, I had to make change supported scripts in_scripts/painless/_execute
API by adding the update context. How can we keep this unit test in this code without modifying the supported scripts? One option is we can keep a setting which users can't modify and set it from the test, using that setting allow the update operation in supported scripts.Related Issues
Resolves #6435
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.