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 visibility of error message during schema retrieval #5879

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

apollonin
Copy link
Contributor

@apollonin apollonin commented Dec 22, 2022

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • New Query Runner (Data Source)
  • New Alert Destination
  • Other

Description

Right now it is impossible to debug the error during schema update. There is not logs in worker logs as well as response from the server is useless in chrome dev tools:
image

With the current change we:

  1. Pass the real error message back to the task response:
    image

  2. Reduce code duplication by consolidating error handling in one place for future improvements.

  3. improve bigQuery error handling to parse json for 404 errors as well as for 400th.

How is this tested?

  • Unit tests (pytest, jest)
  • E2E Tests (Cypress)
  • Manually
  • N/A

I tested this behavior by reproducing the error during schema update operation. With this new change I can clearly see the issue in dev tools as well as in logs.

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

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

Thanks! This indeed will make it easier to debug schema issues. Added some comments.

except Exception:
return {"error": {"code": 2, "message": "Error retrieving schema."}}
except Exception as e:
return {"error": {"code": 2, "message": f"Error retrieving schema: {e}"}}
Copy link
Member

Choose a reason for hiding this comment

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

How about we split it into a separate field (details?). This way we can better format it in the UI.

Copy link
Contributor Author

@apollonin apollonin Dec 30, 2022

Choose a reason for hiding this comment

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

Oh yes, this is a good idea. Let me adjust it here. Thank you for reviewing!

return

logger.error(error)
raise Exception(f"Error during query execution. Reason: {error}")
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the Error during query execution prefix really needed or it might be confusing? (if the error happens when trying to connect, for example)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it used to be "Failed getting schema." which covered only specific query to retrieve a schema. However, now this method is being used to handle errors for the run_query method, which could run different types of queries. so I figured for readability it would be nice to specify the action which led to the error.
For the db connect issue it will still make sense, because technically the error happened during the query operation. However, I'm sure in case of db disconnect we should handle it in a deeper layer and not care during each individual query run.
Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it also aligns with the vision to split message and details so we can report properly the error to the user.

I imagine there could be other types of errors like validation, pre\post checks and so on, that is why this prefix would be useful here.

image

Copy link
Contributor Author

@apollonin apollonin left a comment

Choose a reason for hiding this comment

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

@arikfr thank you again for reviewing. I have addressed your comments and updated the PR

return

logger.error(error)
raise Exception(f"Error during query execution. Reason: {error}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it used to be "Failed getting schema." which covered only specific query to retrieve a schema. However, now this method is being used to handle errors for the run_query method, which could run different types of queries. so I figured for readability it would be nice to specify the action which led to the error.
For the db connect issue it will still make sense, because technically the error happened during the query operation. However, I'm sure in case of db disconnect we should handle it in a deeper layer and not care during each individual query run.
Let me know what you think.

return

logger.error(error)
raise Exception(f"Error during query execution. Reason: {error}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it also aligns with the vision to split message and details so we can report properly the error to the user.

I imagine there could be other types of errors like validation, pre\post checks and so on, that is why this prefix would be useful here.

image

@apollonin apollonin requested a review from arikfr December 30, 2022 18:27
@arikfr arikfr merged commit 5cf13af into getredash:master Jan 5, 2023
@arikfr
Copy link
Member

arikfr commented Jan 5, 2023

👍 thanks.

@apollonin apollonin deleted the better_schema_error_handling branch January 5, 2023 22:09
AkaashK pushed a commit to tharzeez/redash that referenced this pull request Jul 18, 2023
…h#5879)

* handle query execution error in one place. increase ability to debug issues with schema retrieval

* split message and details for error reporting

Co-authored-by: Dmitriy Apollonin <dmitriy.apollonin@aspireiq.com>
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.

2 participants