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

Improve error message when collection name omitted #800

Closed
jeffreyscarpenter opened this issue Jan 16, 2024 · 2 comments · Fixed by #808
Closed

Improve error message when collection name omitted #800

jeffreyscarpenter opened this issue Jan 16, 2024 · 2 comments · Fixed by #808
Assignees

Comments

@jeffreyscarpenter
Copy link
Contributor

jeffreyscarpenter commented Jan 16, 2024

A user reported the following error when executing a command on the JSON API:

{"errors":[{"message":"Could not resolve type id 'insertOne' as a subtype of `io.stargate.sgv2.jsonapi.api.model.command.NamespaceCommand`: Class `io.stargate.sgv2.jsonapi.api.model.command.impl.InsertOneCommand` not subtype of `io.stargate.sgv2.jsonapi.api.model.command.NamespaceCommand`\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled);

The problem is that the insertOne operation is an operation on the collection resource, but the collection name was not included on the URL path (i.e. /api/json/v1//). Let's see if we can give a better error message if a collection command is requested on the namespace resource.

@tatu-at-datastax
Copy link
Contributor

tatu-at-datastax commented Jan 16, 2024

Would it be possible to add specific JSON payload user used to simplify reproduction?

@Yuqi-Du
Copy link
Contributor

Yuqi-Du commented Jan 19, 2024

JSON API should detect the mismatch of provided command with url path.

e.g. 1
{{base_json_url}}{{json_api}}/namespace

{
    "find":{}
}

should prompt No 'find' command found as NamespaceCommand

e.g. 2
{{base_json_url}}{{json_api}}/namespace/collection

{
    "randomGuy":{}
}

should prompt No 'randomGuy' command found as CollectionCommand

e.g. 3
{{base_json_url}}{{json_api}}/namespace/collection

{
    "createNamespace":{}
}

should prompt No 'createNamespace' command found as CollectionCommand

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 a pull request may close this issue.

3 participants