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

[bug] Fix error when attempting to log errors with --log-format json #207

Closed
wants to merge 2 commits into from

Conversation

OwenKephart
Copy link

resolves #206

Description

Instead of attempting to log the bare Exception object, log the stringified version of it. This will have no impact on the default logging behavior, while allowing this message to be json serializable.

The contributing guide mentions using changie for changelog entries, but it doesn't seem like that's set up for this subrepo, let me know if I'm missing something!

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-bigquery next" section.

@cla-bot cla-bot bot added the cla:yes label Jun 28, 2022
@dataders dataders requested review from a team and VersusFacit June 29, 2022 00:20
@dataders dataders added the type:bug Something isn't working label Jun 29, 2022
# the google bigquery library likes to add the query log, which we
# don't want to log. Hopefully they never change this!
if BQ_QUERY_JOB_SPLIT in exc_message:
exc_message = exc_message.split(BQ_QUERY_JOB_SPLIT)[0].strip()
logger.debug(exc_message)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to happen within the if BQ_QUERY_JOB_SPLIT in exc_message: block?

Suggested change
logger.debug(exc_message)
logger.debug(exc_message)

Copy link
Author

Choose a reason for hiding this comment

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

@dataders I don't have strong feelings here, but in the original implementation, the error message would be logged in all scenarios (as logger.debug(e) was outside of all conditionals). In the proposed version, the error message would not be logged in the scenario that the Exception was not a RuntimeException, and BQ_QUERY_JOB_SPLIT was not in exc_message.

I might have over-indexed on the comment saying "...likes to add the query log, which we don't want to log". I took that to mean that it would be incorrect to log the query log stuff even in the debug logs (so I only logged the exc_message once that had been filtered out). If that stuff is ok to make it into debug-level logs, then I think the best approach is to log the entire exc_message (pre-split) at the top of this function.

Happy to go in whichever direction with this though!

@jtcohen6
Copy link
Contributor

I'm going to close this PR, insofar as we'd like to try resolving the root cause in dbt-core (dbt-labs/dbt-core#5436). If we can't find a path forward there, we can reopen and apply the patch here for the short/medium term.

@jtcohen6 jtcohen6 closed this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-784] When using --log-format json, exceptions during query execution result in JSON Serialization errors
3 participants