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

Block commas in model description #1692

Merged

Conversation

ryanbogan
Copy link
Member

@ryanbogan ryanbogan commented May 6, 2024

Description

When commas are present in the model description, the model metadata is not parsed correctly, resulting in an exception being thrown when ingesting data to or searching on a model-based index. This PR throws an IllegalArgumentException if the user attempts to create a model with a comma in the model description.

Issues Resolved

#1337
#1479

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as 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.

ryanbogan added 2 commits May 6, 2024 12:31
@ryanbogan
Copy link
Member Author

Rolling upgrade failures unrelated: #1691

@@ -123,6 +126,9 @@ public ModelMetadata(
this.state = new AtomicReference<>(Objects.requireNonNull(modelState, "modelState must not be null"));
this.timestamp = Objects.requireNonNull(timestamp, "timestamp must not be null");
this.description = Objects.requireNonNull(description, "description must not be null");
if (this.description.contains(",")) {
throw new IllegalArgumentException("Model description cannot contain any commas: ','");
Copy link
Member

Choose a reason for hiding this comment

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

nit: may be "model" instead of "Model"? i see every other exception message doesn't start with caps.

Copy link
Member Author

@ryanbogan ryanbogan May 7, 2024

Choose a reason for hiding this comment

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

All of the null check exceptions are lower case, but the other IllegalArgumentException earlier in the method that validates the max dimensions starts with a cap:
https://github.com/opensearch-project/k-NN/pull/1692/files#diff-b1d2b535ac05d02aee28ed7164936b0f35b893746c09eb24e705c9e1cfd3fed2R118

@jmazanec15
Copy link
Member

Can we add the check in the rest handler as well as ModelMetadata? Im just thinking we should fail fast on this when possible (i.e. before any transport requests are sent or state is serialized)

jmazanec15
jmazanec15 previously approved these changes May 7, 2024
@ryanbogan ryanbogan requested a review from VijayanB May 8, 2024 17:17
Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.98%. Comparing base (771c4b5) to head (f745d09).
Report is 31 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1692      +/-   ##
============================================
+ Coverage     84.92%   84.98%   +0.06%     
- Complexity     1375     1459      +84     
============================================
  Files           172      176       +4     
  Lines          5605     5854     +249     
  Branches        553      597      +44     
============================================
+ Hits           4760     4975     +215     
- Misses          612      628      +16     
- Partials        233      251      +18     

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

Copy link
Member

@martin-gaievski martin-gaievski left a comment

Choose a reason for hiding this comment

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

looks good to me, thank you

@ryanbogan ryanbogan merged commit 011775a into opensearch-project:main May 8, 2024
58 of 60 checks passed
@ryanbogan ryanbogan deleted the comma_model_description branch May 8, 2024 22:54
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

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
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1692-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 011775a208002547c9080fc9423399ea500faa52
# Push it to GitHub
git push --set-upstream origin backport/backport-1692-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1692-to-2.x.

luyuncheng pushed a commit to luyuncheng/k-NN-1 that referenced this pull request May 22, 2024
* Block commas in model description

Signed-off-by: Ryan Bogan <[email protected]>

* Add changelog entry

Signed-off-by: Ryan Bogan <[email protected]>

* Add check in rest handler

Signed-off-by: Ryan Bogan <[email protected]>

* Extract if statement into ModelUtil method

Signed-off-by: Ryan Bogan <[email protected]>

* Remove ingestion from integ test

Signed-off-by: Ryan Bogan <[email protected]>

---------

Signed-off-by: Ryan Bogan <[email protected]>
luyuncheng pushed a commit to luyuncheng/k-NN-1 that referenced this pull request May 22, 2024
* Block commas in model description

Signed-off-by: Ryan Bogan <[email protected]>

* Add changelog entry

Signed-off-by: Ryan Bogan <[email protected]>

* Add check in rest handler

Signed-off-by: Ryan Bogan <[email protected]>

* Extract if statement into ModelUtil method

Signed-off-by: Ryan Bogan <[email protected]>

* Remove ingestion from integ test

Signed-off-by: Ryan Bogan <[email protected]>

---------

Signed-off-by: Ryan Bogan <[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.

4 participants