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

error out with invalid option when createCollection #832

Merged
merged 5 commits into from
Jan 25, 2024

Conversation

Yuqi-Du
Copy link
Contributor

@Yuqi-Du Yuqi-Du commented Jan 24, 2024

When user provides an invalid option when createCollection,
currently, we have three options (case sensitive): vector, vectorize, indexing

Example:

{
    "createCollection": {
        "name": "tableEx",
        "options": {
            "Yuqi": {}
        }
    }
}
{
    "errors": [
        {
            "message": "The provided options is invalid: No option "Yuqi" found as createCollectionCommand option,  (known options: "indexing", "vector")",
            "errorCode": "INVALID_CREATE_COLLECTION_OPTIONS"
        }
    ]
}

Which issue(s) this PR fixes:
Fixes #828

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@Yuqi-Du Yuqi-Du requested a review from a team as a code owner January 24, 2024 20:17
throws IOException {
if (deserializer.handledType().toString().endsWith("CreateCollectionCommand$Options")) {
throw ErrorCode.INVALID_CREATE_COLLECTION_OPTIONS.toApiException(
"No option \"%s\" found as createCollectionCommand option", propertyName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is helpful: but even more helpful I think would be listing 2 existing options in addition?
Something like:

"No option \"%s\" found as createCollectionCommand option (known options: \"indexing\", \"vector\")",

Copy link
Contributor

Choose a reason for hiding this comment

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

(not sure if "vectorize" should be included; it is technically allowed, but not publicly supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

solved, thanks

Copy link
Contributor

@tatu-at-datastax tatu-at-datastax 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: added suggestions. Interesting way of dealing with the issue, nice!

@Yuqi-Du Yuqi-Du merged commit 147ea1f into main Jan 25, 2024
2 checks passed
@Yuqi-Du Yuqi-Du deleted the invalid_option_createCollection branch January 25, 2024 17:48
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add validation of "options" property of createCollection command to avoid silent failures
3 participants