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

adds inputs validation for create memory #2034

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

Zhangxunmt
Copy link
Collaborator

@Zhangxunmt Zhangxunmt commented Feb 6, 2024

Description

This is to address the Null value of the "name" in create a memory in the exceptions described here #1997. They should be all handled with 400 error code.

Before this change:

POST /_plugins/_ml/memory
{
  "name": null
}

Response:
{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"Can't get text on a VALUE_NULL at 2:8"}],"type":"illegal_state_exception","reason":"Can't get text on a VALUE_NULL at 2:8"},"status":500}
POST /_plugins/_ml/memory
{
  "name": 999999999999999999999.....
}

Response:
{"error":{"root_cause":[{"type":"stream_constraints_exception","reason":"Number length (5628) exceeds the maximum length (1000)"}],"type":"stream_constraints_exception","reason":"Number length (5628) exceeds the maximum length (1000)"},"status":500}

After this change:

POST /_plugins/_ml/memory
{
  "name": null
}

Response:
{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "Can't get text on a VALUE_NULL at 2:11"
      }
    ],
    "type": "parse_exception",
    "reason": "Can't get text on a VALUE_NULL at 2:11"
  },
  "status": 400
}


POST /_plugins/_ml/memory
{
  "name": 999999999999999999999.....
}

Response:
{"error":{"root_cause":[{"type":"stream_constraints_exception","reason":"Number length (5628) exceeds the maximum length (1000)"}],"type":"stream_constraints_exception","reason":"Number length (5628) exceeds the maximum length (1000)"},"status":400}

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.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8bd9592) 82.57% compared to head (24e30fb) 82.58%.
Report is 1 commits behind head on main.

Files Patch % Lines
...action/conversation/CreateConversationRequest.java 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2034   +/-   ##
=========================================
  Coverage     82.57%   82.58%           
- Complexity     5600     5602    +2     
=========================================
  Files           542      542           
  Lines         22536    22540    +4     
  Branches       2293     2293           
=========================================
+ Hits          18610    18614    +4     
  Misses         2991     2991           
  Partials        935      935           
Flag Coverage Δ
ml-commons 82.58% <80.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Collaborator

@HenryL27 HenryL27 left a comment

Choose a reason for hiding this comment

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

I feel like try/catch is a bit of a hack but ok, it works

@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env February 6, 2024 23:11 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env February 6, 2024 23:11 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env February 6, 2024 23:11 — with GitHub Actions Inactive
@HenryL27
Copy link
Collaborator

HenryL27 commented Feb 6, 2024

Also not entirely clear what the diff is before/after, judging from the pr description?

@Zhangxunmt
Copy link
Collaborator Author

Also not entirely clear what the diff is before/after, judging from the pr description?

It’s the status code returning should be 400.

@Zhangxunmt Zhangxunmt merged commit 864d349 into opensearch-project:main Feb 7, 2024
15 of 17 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 7, 2024
Signed-off-by: Xun Zhang <[email protected]>
(cherry picked from commit 864d349)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 7, 2024
Signed-off-by: Xun Zhang <[email protected]>
(cherry picked from commit 864d349)
Zhangxunmt added a commit that referenced this pull request Feb 7, 2024
Signed-off-by: Xun Zhang <[email protected]>
(cherry picked from commit 864d349)

Co-authored-by: Xun Zhang <[email protected]>
Zhangxunmt added a commit that referenced this pull request Feb 7, 2024
Signed-off-by: Xun Zhang <[email protected]>
(cherry picked from commit 864d349)

Co-authored-by: Xun Zhang <[email protected]>
austintlee pushed a commit to austintlee/ml-commons that referenced this pull request Mar 19, 2024
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.

3 participants