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

Update formatting for errors and query info #563

Merged
merged 13 commits into from
Jan 17, 2025
Merged

Conversation

ptpaterson
Copy link
Contributor

@ptpaterson ptpaterson commented Jan 15, 2025

issues: FE-6013, FE-6285

While I was working on the displaying aborts and constraint failures, I wasn't sure how it would play with query info, so I ended up working on these together. If this is too much at once, I can split them out into separate PRs.

update: same deal with printing metrics for successful v4 queries. I just noticed that that wasn't wired up, so I tacked that on, but we can still split if that helps.

Problem

Query info fields specified with --include are not displayed with errors.

v10 aborts and constraint failures come with additional information that is not displayed.

v4 errors don't look like v10 errors.

--include options middleware is not being used for the shell command.

Also, query info is not being printed for successful v4 queries.

Solution

Refactor formatQueryInfo into the separate functions within the fauna.mjs and faunadb.mjs modules.

  • This gives us access to formatQueryInfo in each of the modules' formatError methods.

Pipe the include option into formatError.

  • make sure that the shell command resolves include options using provided middleware.

Update query and shell commands to show v4 metrics with --include stats is used.

Modify v10 formatError

  • Insert query info with yaml formatting above the error.
  • remove "summary" from the list of things to include, because an error always includes a summary, and the summary is what we want to display to folks on error.
  • If the error is an abort or contraint failure, then add additional information under the error summary.

Modify v10 formatError

  • insert query info with yaml formatting above the error.
  • keep the basic error message the same: code + description
  • move the position info to a line underneath and add "*query*" to make it look more like a v10 error
  • There's nothing special about abort or constraint failure errors in v4

Result

Users can get all the information from errors that they want.

v10

before
image

after
image

abort before
image

abort after
image

It's a little weird when other summary bits are included in errors, but that's no different than how it is now.

image

v4

before
image

after
image

shell

Works there too
image

image

Testing

Added tests for

  • showing query info for v10 errors
  • showing abort and contraint failure info on those errors
  • showing query info for successful v4 queries
  • showing query info ofor v4 errors

@ptpaterson ptpaterson marked this pull request as ready for review January 16, 2025 17:21
@ptpaterson ptpaterson requested a review from a team as a code owner January 16, 2025 17:21
@ptpaterson ptpaterson changed the title Add additional info to query errors Update formatting for errors and query info Jan 16, 2025
@ptpaterson ptpaterson merged commit 36461e2 into main Jan 17, 2025
4 checks passed
@ptpaterson ptpaterson deleted the fe-6013-abort-info branch January 17, 2025 14:32
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.

3 participants