airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Fix a potential variable misuse bug

Open LostBenjamin opened this issue 2 years ago • 6 comments

Hi,

This pull request is a fix to a potential variable misuse bug at airflow/models/dagrun.py. Please check the changes.

Given the surrounding context, it seems to me that the correct variable should be ti.

Best, Jingxuan

LostBenjamin avatar Jun 15 '22 12:06 LostBenjamin

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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst) Here are some useful points:

  • Pay attention to the quality of your code (flake8, 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. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] Slack: https://s.apache.org/airflow-slack

boring-cyborg[bot] avatar Jun 15 '22 12:06 boring-cyborg[bot]

This bug was spotted by our automated tool statically. I am not familiar with the codebase so it would be difficult for me to add a test.

LostBenjamin avatar Jun 15 '22 13:06 LostBenjamin

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 04 '22 00:08 github-actions[bot]

Any news on this?

LostBenjamin avatar Aug 04 '22 06:08 LostBenjamin

It seems like that part of the codebase will never be reached. It looks like a legacy code that needs cleaning. Doesn't seem to do anything

ephraimbuddy avatar Aug 04 '22 07:08 ephraimbuddy

This is super ancient 8c42d03c4e35a0046e46f0e2e6db588702ee7e8b. The surrounding block seems reachable to me though? It essentially checks whether an existing task instance is still “relevant” i.e. the corresponding task is gone, and mark the ti as removed if needed.

uranusjr avatar Aug 04 '22 08:08 uranusjr

This bug was spotted by our automated tool statically. I am not familiar with the codebase so it would be difficult for me to add a test.

Which tool was it out of interst?

ashb avatar Sep 08 '22 08:09 ashb

The tool based one our latest ICML'22 paper. Link to the paper and the repo.

LostBenjamin avatar Sep 08 '22 09:09 LostBenjamin

This bug was spotted by our automated tool statically. I am not familiar with the codebase so it would be difficult for me to add a test.

Interesting, but I think without the automated false-positive detection and lack of reasoning leading to why it should be fixed it might be more noise than help.

Suggestion for furrher research in this area: Would be great if the tool also produced a likely "test" that tests the behaviour (and fails befiore and succeeds after). That would be a fantastic tool, as having tests whike reviewing is usually more productive than the code.

potiuk avatar Sep 08 '22 09:09 potiuk

Interesting, but I think without the automated false-positive detection and lack of reasoning leading to why it should be fixed it might be more noise than help.

To be honest, during our manual inspection, we were also unsure if this case is a true bug or a false positive. But we made this PR so that we don't miss a possibly true bug, expecting someone who knows the codebase to correctly judge it. Other PRs we made to other repos (see the list at the end of the paper) were more clear and almost all of them were merged.

Suggestion for furrher research in this area: Would be great if the tool also produced a likely "test" that tests the behaviour (and fails befiore and succeeds after). That would be a fantastic tool, as having tests whike reviewing is usually more productive than the code.

Thanks for your suggestion! We will try to investigate on this.

LostBenjamin avatar Sep 08 '22 10:09 LostBenjamin

Do you have any more reasoning/test case that we can add here @LostBenjamin ?

potiuk avatar Sep 18 '22 19:09 potiuk

@potiuk

No.

LostBenjamin avatar Sep 18 '22 19:09 LostBenjamin

Then I close it.

potiuk avatar Sep 18 '22 19:09 potiuk