Skip to content
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

add parameter validate for PPL tool #259

Merged
merged 8 commits into from
Mar 18, 2024

Conversation

xinyual
Copy link
Collaborator

@xinyual xinyual commented Mar 14, 2024

Description

add parameter validate for PPL tool:

  1. Model id should not be null or blank
  2. Head should be integer
  3. Execute should be false or true

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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: xinyual <[email protected]>
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 81.62%. Comparing base (cbe5fa2) to head (739c680).
Report is 2 commits behind head on main.

Files Patch % Lines
.../main/java/org/opensearch/agent/tools/PPLTool.java 85.71% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #259      +/-   ##
============================================
+ Coverage     81.57%   81.62%   +0.05%     
- Complexity      211      216       +5     
============================================
  Files            13       13              
  Lines          1069     1083      +14     
  Branches        146      149       +3     
============================================
+ Hits            872      884      +12     
  Misses          140      140              
- Partials         57       59       +2     

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

Signed-off-by: xinyual <[email protected]>
throw new IllegalArgumentException("PPL tool needs non blank model id.");
}
if (map.containsKey("execute")) {
String execute = map.get("execute").toString().toLowerCase(Locale.ROOT);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible the map.get("execute") is null? if yes, it could produce NPE here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change the logic to prevent it. Please check it. From my perspective, these parameters are from register body and couldn't be null. But anyway, it's better to have it.

Signed-off-by: xinyual <[email protected]>
xinyual added 2 commits March 15, 2024 09:33
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
xinyual added 2 commits March 18, 2024 15:31
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
@zane-neo zane-neo merged commit 571dab7 into opensearch-project:main Mar 18, 2024
18 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 18, 2024
* add parameter validate for PPL tool

Signed-off-by: xinyual <[email protected]>

* apply spotless

Signed-off-by: xinyual <[email protected]>

* simplify code

Signed-off-by: xinyual <[email protected]>

* prevent NPE

Signed-off-by: xinyual <[email protected]>

* change logic

Signed-off-by: xinyual <[email protected]>

* apply spot

Signed-off-by: xinyual <[email protected]>

* fix UT

Signed-off-by: xinyual <[email protected]>

* apply spotless

Signed-off-by: xinyual <[email protected]>

---------

Signed-off-by: xinyual <[email protected]>
(cherry picked from commit 571dab7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
xinyual pushed a commit that referenced this pull request Mar 18, 2024
* add parameter validate for PPL tool



* apply spotless



* simplify code



* prevent NPE



* change logic



* apply spot



* fix UT



* apply spotless



---------


(cherry picked from commit 571dab7)

Signed-off-by: xinyual <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
yuye-aws pushed a commit to yuye-aws/skills that referenced this pull request Apr 26, 2024
…rch-project#262)

* add parameter validate for PPL tool

* apply spotless

* simplify code

* prevent NPE

* change logic

* apply spot

* fix UT

* apply spotless

---------

(cherry picked from commit 571dab7)

Signed-off-by: xinyual <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: yuye-aws <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants