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

Add custom error msgs for query validation failures #538

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

cap10morgan
Copy link
Contributor

@cap10morgan cap10morgan commented Jul 21, 2023

Closes #535

Adds custom user-friendlier error messages for missing top-level query keys (exclusively for now to get a sense of the contours of the general solution here). I also implemented custom messages for extraneous top-level query keys, which required setting the query map schema as "closed." But that seemed like what we probably wanted anyway?

I also cleaned up the query schema in a couple ways:

  • I removed extraneous schema aliases that only existed to match map keys. These were extraneous because the :map schema itself points map keys at whichever value schema you want, and they are perfectly happy to reuse a value schema with a different name.
  • I renamed the ::analytical-query schema to just ::query and deleted the old ::query schema b/c it was trying to validate either a single or a multi-query. Those have their own API fns / entrypoints so we didn't actually need to validate either kind of query in a single context. Doing so was polluting the error messages with lots of extra, useless information when it tried to validate invalid single queries as multi-queries as a fallback.

My goals with the error messages were:

  1. Show the query that generated the error
  2. Give the user a concise but actionable description of what went wrong and what they need to do to fix it
  3. Give the user a place they can go to get more information if they need it. This needs collaboration with @fluree/devrel to setup the /errorcodes landing page which these messages link to. They are preliminarily on board with this based on this Slack conversation. We will need to coordinate adding the referenced error codes before merging this PR and in future PRs, as well as adding error code links to other existing error messages.

We should open additional issues to address other categories of errors in a similar fashion.

@cap10morgan cap10morgan requested review from aaj3f and a team July 21, 2023 18:47
@cap10morgan
Copy link
Contributor Author

The devrel side of the error codes landing page is happening here: https://github.com/fluree/devrel/issues/117

Copy link
Contributor

@zonotope zonotope left a comment

Choose a reason for hiding this comment

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

🌾

@cap10morgan cap10morgan merged commit e16a72e into main Jul 24, 2023
5 checks passed
@cap10morgan cap10morgan deleted the feature/humanized-error-messages branch July 24, 2023 17:17
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.

Return user-actionable English error messages for missing top-level query keys
2 participants