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 confusing error messages for JS client #70

Open
Migweld opened this issue Jan 16, 2020 · 1 comment
Open

Improve confusing error messages for JS client #70

Migweld opened this issue Jan 16, 2020 · 1 comment

Comments

@Migweld
Copy link

Migweld commented Jan 16, 2020

Is your feature request related to a problem? Please describe.
Syntax errors within GROQ queries throw a 'Must be an attribute or string key' error. The stacktrace doesn't give a great deal of information as to where the problem is. Example below:

Very simple mistake to make. Missing comma after 'slug':

`
    {
      "work": *[_type == "caseStudies"]{
        title,
        slug
        tags,
      }
    }
  `

Error message given:

Must be an attribute or a string keyClientError: Must be an attribute or a string key
    at onResponse (/Users/craig/Documents/projects/flo-site-v5/node_modules/@sanity/client/lib/http/request.js:27:13)
    at /Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/util/middlewareReducer.js:10:22
    at Array.reduce (<anonymous>)
    at applyMiddleware (/Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/util/middlewareReducer.js:9:29)
    at onResponse (/Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/index.js:81:22)
    at /Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/index.js:48:55
    at callback (/Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/request/node-request.js:57:46)
    at /Users/craig/Documents/projects/flo-site-v5/node_modules/get-it/lib-node/request/node-request.js:141:14
    at DestroyableTransform.<anonymous> (/Users/craig/Documents/projects/flo-site-v5/node_modules/simple-concat/index.js:7:13)
    at Object.onceWrapper (events.js:312:28)
    at DestroyableTransform.emit (events.js:228:7)
    at endReadableNT (/Users/craig/Documents/projects/flo-site-v5/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Describe the solution you'd like
Relevant error messages, perhaps as a result of validation of the GROQ query itself.

@vicmeow
Copy link
Contributor

vicmeow commented Jan 16, 2020

Thanks for reporting! More useful messaging would definitely benefit us all!

@rexxars rexxars transferred this issue from sanity-io/sanity Dec 14, 2022
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

No branches or pull requests

2 participants