Skip to content

Fix possible NPE in RestTasksAction.java #17778

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

Conversation

ngr-ilmarh
Copy link
Contributor

@ngr-ilmarh ngr-ilmarh commented Apr 3, 2025

Description

Fix possible NPE in _cat/tasks reply table preparation in case of node, that left cluster during query process.

No tests were run, i think this is useless here

Related Issues

Resolves #17762

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

Signed-off-by: Ilmar S. Habibulin <[email protected]>
Copy link
Contributor

github-actions bot commented Apr 3, 2025

❕ Gradle check result for adc9466: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 72.45%. Comparing base (c91cdcb) to head (de80ca0).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...rg/opensearch/rest/action/cat/RestTasksAction.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17778      +/-   ##
============================================
- Coverage     72.46%   72.45%   -0.01%     
- Complexity    66502    66533      +31     
============================================
  Files          5408     5408              
  Lines        308080   308155      +75     
  Branches      44720    44737      +17     
============================================
+ Hits         223239   223273      +34     
- Misses        66536    66642     +106     
+ Partials      18305    18240      -65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrross
Copy link
Member

andrross commented Apr 3, 2025

I think it would be pretty easy to improve the unit tests to hit this scenario. I think if you add a TaskInfo to be returned in the response of the unit test here that will work. Something like:

final TaskInfo taskInfo = new TaskInfo(
    new TaskId("test-node-id", randomLong()),
    "test_type",
    "test_action",
    "test_description",
    null,
    randomLong(),
    randomLong(),
    false,
    false,
    TaskId.EMPTY_TASK_ID,
    Map.of("foo", "bar"),
    randomResourceStats(randomBoolean())
);
listener.onResponse((Response) new ListTasksResponse(List.of(taskInfo), emptyList(), emptyList()));

@ngr-ilmarh
Copy link
Contributor Author

Sorry, can't deepdive right now in OS internals, just copypasted your proposal.
Test coverage will be recalculated automatically?

Copy link
Contributor

github-actions bot commented Apr 4, 2025

❌ Gradle check result for aa22955: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@andrross
Copy link
Member

andrross commented Apr 4, 2025

Thanks @ngr-ilmarh! This looks good, but there are some missing imports plus a bug with one of those random longs in the test. For some reason I'm not able to push a commit to this pull request, but you can either fix up those errors or cherry pick this commit from my user fork: andrross@854e0cd

@ngr-ilmarh
Copy link
Contributor Author

OK, will be back next Monday, thanks for example

Copy link
Contributor

github-actions bot commented Apr 7, 2025

❌ Gradle check result for 065de7c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ngr-ilmarh
Copy link
Contributor Author

I've used my organisation repository for this PR, i think this is the reason, why you are unable to push directly @andrross
Cherrypicked imports and random changes, but built (tests) failed. I checked errors, they seems to be not related to this patch

Copy link
Contributor

github-actions bot commented Apr 8, 2025

❌ Gradle check result for de80ca0: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@andrross
Copy link
Member

andrross commented Apr 8, 2025

Thanks @ngr-ilmarh! This looks good. There are indeed flaky tests unrelated to this change. I'll make sure the tests pass and get this merged.

Copy link
Contributor

github-actions bot commented Apr 8, 2025

❌ Gradle check result for de80ca0: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

github-actions bot commented Apr 8, 2025

✅ Gradle check result for de80ca0: SUCCESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[BUG] possible NPE in RestTasksAction.java found by SAST
2 participants