Skip to content

Conversation

@aboitreaud
Copy link
Contributor

@aboitreaud aboitreaud commented Sep 5, 2024

Fix a typo in error stack trace formatting by replacing "\\n" joins with traceback.format_exc(). The previous implementation used "\\n" to join lines, resulting in "\n" printed at the beginning of the lines. Fixing it by joining on "\n" would just add unnecessary line breaks and extra spacing in the stack trace. Since traceback functions already handle line breaks, this fix ensures proper formatting without redundant joins.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg
Copy link

boring-cyborg bot commented Sep 5, 2024

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@JDarDagran
Copy link
Contributor

@kacpermuda could you please comment on that? I can see you made current join in #39813

@kacpermuda
Copy link
Contributor

Hey @aboitreaud , thanks for the PR ! Apart from the problem you described with the formatting, you are not passing the exception object anymore to the formatting func. I'm thinking if there possibly is some edge case, where we the last exception raised is not the one that we have here in the adapter. Have you considered it here?

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

Does this change the error message? If so, can we include a comparison between old and new outputs in this PR?

@aboitreaud
Copy link
Contributor Author

aboitreaud commented Sep 13, 2024

Hi @kacpermuda and @uranusjr and thanks for your comments!
Good catch, and thanks for pointing that out! I hadn’t fully considered the possibility of an edge case where the last exception raised might not be the one we have here in the adapter. To address this, I’m reverting back to using traceback.format_exception(error) instead of relying on traceback.format_exc(). This ensures we are handling the correct exception in all cases.

However, I don't think that joining on "\n" is necessary, here is of what the stack trace would look like:

  • the old output, by joining on "\\n":
Traceback (most recent call last):
\n  File "example.py", line 6, in cause_error
    result = 1 / 0
\nZeroDivisionError: division by zero
  • by joining on "\n":
Traceback (most recent call last):

  File "example.py", line 6, in cause_error
    result = 1 / 0

ZeroDivisionError: division by zero
  • the new output, by joining on "":
Traceback (most recent call last):
  File "example.py", line 6, in cause_error
    result = 1 / 0
ZeroDivisionError: division by zero

@aboitreaud aboitreaud requested a review from uranusjr September 13, 2024 08:46
@aboitreaud
Copy link
Contributor Author

aboitreaud commented Sep 17, 2024

@uranusjr could I please also get your approval following Kacper's please ?

@aboitreaud
Copy link
Contributor Author

👊 Gentle bump here @uranusjr @mobuchowski, could I get a code owner review please ?

@mobuchowski mobuchowski merged commit ffff0e8 into apache:main Sep 23, 2024
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 23, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@aboitreaud aboitreaud deleted the openLineage-fix-error-stack-traces branch September 23, 2024 14:30
joaopamaral pushed a commit to joaopamaral/airflow that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants