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

Handle error when the namespace doesn't exist #557

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

Hazel-Datastax
Copy link
Contributor

@Hazel-Datastax Hazel-Datastax commented Oct 6, 2023

What this PR does:

  1. Add error message if namespace is not found

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

Checklist

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

@Hazel-Datastax Hazel-Datastax requested a review from a team as a code owner October 6, 2023 19:26
@tatu-at-datastax
Copy link
Contributor

As we discussed, one good starting point is writing a (failing) integration test, and work from that. Change itself seems reasonable, although I wonder if missing/mistyped Table name would also result in NOT_FOUND. It is also good to indicate actual value that does not match (name of keyspace that is not found).

new RuntimeException(
new JsonApiException(
ErrorCode.NAMESPACE_DOES_NOT_EXIST,
"The provided namespace does not exist: " + namespace)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this meant to improve the following error that happens when you call find() on a collection that doesn't exist?

Error: Command "find" failed with the following errors: [{"message":"INVALID_ARGUMENT: table articles22 does not exist","exceptionClass":"StatusRuntimeException"}]

Copy link
Contributor

Choose a reason for hiding this comment

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

@vkarpov15 I think this is about namespace, not collection (table)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means to improve the error when the namespace doesn't exist, not the collection. I guess you got the error when you input the wrong collection name (or table showed in the error message).

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.

I second @tatu-at-datastax , an integration test that demonstrates how this error message is triggered would be excellent.

startsWith(
"Failed to insert document with _id 'doc4': INVALID_ARGUMENT: keyspace something_else does not exist"))
.body("errors[0].exceptionClass", is("StatusRuntimeException"));
.body("errors[0].message", startsWith("The provided namespace does not exist"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor improvement request: check that namespace name is matched too (since it is now included).

@tatu-at-datastax
Copy link
Contributor

Looks good so far: just needs one or more additional integration tests -- at least one more for one of "find" commands.

@Hazel-Datastax
Copy link
Contributor Author

Looks good so far: just needs one or more additional integration tests -- at least one more for one of "find" commands.

Thank you for mentioning that. I added one more integration test for the find command.

Copy link
Contributor

@maheshrajamani maheshrajamani left a comment

Choose a reason for hiding this comment

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

LGTM

@Hazel-Datastax Hazel-Datastax merged commit 5e278dd into main Oct 11, 2023
3 checks passed
@Hazel-Datastax Hazel-Datastax deleted the hazel/error-message branch October 11, 2023 17:20
@Hazel-Datastax
Copy link
Contributor Author

Close issue #545

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.

Json api messaging if namespace is not found.
4 participants