Skip to content

Conversation

@wei-juncheng
Copy link
Contributor

@wei-juncheng wei-juncheng commented Jan 26, 2025

closes: #42720

  • Implementation
  • E2E Test
  • Unit Test

What does this PR do?

  • Fix the error on the XCom filter page in the UI, which is preventing users from using values as filter conditions to select the XCom records they want.

Change details

  • airflow/www/utils.py:
    • Add XComFilterStartsWith, XComFilterEndsWith, XComFilterEqual, XComFilterContains, XComFilterNotStartsWith, XComFilterNotEndsWith, XComFilterNotContains, and XComFilterNotEqual classes to handle different types of filtering for XCom values.

      • Since the value is stored in the xcom table in PostgreSQL's bytea format, we first need to convert it into a UTF-8 string. Additionally, because the value content is enclosed in double quotes before being encoded as bytea and stored in the database, we also need to remove the leading and trailing double quotes from the UTF-8 formatted value in order to compare it with the user's input filter condition.
        • describe xcom table:
          • 截圖 2025-01-26 下午8 46 14
          • 截圖 2025-01-26 下午8 43 39
          • 截圖 2025-01-27 下午1 03 18
    • Updated the AirflowFilterConverter class to include the new XCom filters in its conversion table.

    • Add the is_xcom_value method to check if a column name corresponds to an XCom value.

  • tests/www/test_utils.py:
    • Add a unit test case TestXComFilter to test whether the SQLAlchemy call sequence behaves as expected.

How did you test?

  • Unit Test in tests/www/test_utils.py
  • E2E Test
    • I used the example code provided by Airflow to push the XCom content to the database during DAG execution, and then I operated the XCom filter on the Web UI.

      • 截圖 2025-01-27 下午12 39 49
    • Below are the demo screenshots for each of the functionalities.

      • Demo screenshots:
        • Starts With:

        • 截圖 2025-01-27 下午12 40 17
        • Ends With:

        • 截圖 2025-01-27 下午12 40 46
        • Equal:

        • 截圖 2025-01-27 下午12 41 07
        • Contains:

        • 截圖 2025-01-27 下午12 41 24
        • Not Starts With:

        • 截圖 2025-01-27 下午12 41 37
        • Not Ends With:

        • 截圖 2025-01-27 下午12 42 16
        • Not Contains With:

        • 截圖 2025-01-27 下午12 42 34
        • Not Equal:

        • 截圖 2025-01-27 下午12 43 07

^ 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 boring-cyborg bot added the area:webserver Webserver related Issues label Jan 26, 2025
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 26, 2025

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

@wei-juncheng wei-juncheng marked this pull request as draft January 26, 2025 06:58
@eladkal
Copy link
Contributor

eladkal commented Jan 26, 2025

AI spam

@eladkal eladkal closed this Jan 26, 2025
@wei-juncheng
Copy link
Contributor Author

Hi @eladkal
I apologize. I am the new contributor to this project. Over the past few days, I had an offline handover with @josix regarding this issue, and I will be responsible moving forward. However, while preparing the PR, I accidentally clicked on "create PR." I’m sorry for the disruption. Once the PR is ready, I will re-open it for your review. 🙏🏽

@josix
Copy link
Contributor

josix commented Jan 26, 2025

Hi @eladkal, sorry to bother you. I’m trying to have @wei-juncheng take over the testing part for #45679 as his first contribution to Airflow. Since he’s new to OSS contributions, his profile doesn’t have many contribution records yet.

@wei-juncheng could you help add more information about what the PR has made and also correct the status to Draft if it is not ready, I'll also close my original PR to avoid confusion, thanks!

@Lee-W
Copy link
Member

Lee-W commented Jan 26, 2025

Hi @eladkal,

Thank you for working on filtering potential AI spam. 😊

I wanted to give you a quick heads-up. I know @josix personally, and he has already created a few pull requests (PRs) and even presented them at the Airflow Town Hall. Additionally, @wei-juncheng is a local community member from Taiwan who is interested in contributing to Airflow and has just started his journey in OSS contributions. I've asked @wei-juncheng to create another PR with more details so he can continue working on this issue and avoid making his PR look like spam. Sorry for the disruption. 🙏

@eladkal
Copy link
Contributor

eladkal commented Jan 26, 2025

Ah cool :)

@eladkal eladkal reopened this Jan 26, 2025
@eladkal eladkal removed the AI Spam label Jan 26, 2025
@Lee-W
Copy link
Member

Lee-W commented Jan 26, 2025

Ah cool :)

ah... yes, we can just reopen it haha. Thanks so much for helping out!

@wei-juncheng wei-juncheng changed the title Fix/42720/x com search on filter value errors fix(XCom): /xcom/list got exception when applying filter on the value column Jan 26, 2025
@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from 416ef22 to 5c6bc71 Compare January 26, 2025 16:58
@wei-juncheng wei-juncheng marked this pull request as ready for review January 27, 2025 05:39
@Lee-W Lee-W self-requested a review January 27, 2025 10:21
@eladkal eladkal added this to the Airflow 2.10.5 milestone Feb 1, 2025
@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Feb 1, 2025
@eladkal eladkal removed this from the Airflow 2.10.5 milestone Feb 1, 2025
@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from 5c6bc71 to 2fab1b6 Compare February 3, 2025 16:04
@wei-juncheng wei-juncheng requested a review from Lee-W February 3, 2025 16:15
Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

It mostly looks good to me, but I have some nitpicks. I propose a new way to implement the utility function; however, I'm not sure if it actually simplifies things. If it doesn't, we can just resolve those f-strings once.

@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from 2fab1b6 to 88e855d Compare February 4, 2025 16:49
@wei-juncheng wei-juncheng requested a review from Lee-W February 4, 2025 16:55
reduce code duplication and add type annotation

fix

fix

fix
@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from 88e855d to d97f25b Compare February 5, 2025 10:04
@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from d97f25b to e9f7079 Compare February 5, 2025 15:56
@wei-juncheng wei-juncheng requested a review from Lee-W February 5, 2025 15:58
Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

LGTM. will keep it for a few days so that others can take a look

@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from e9f7079 to 3d6c522 Compare February 6, 2025 03:57
use @pytest.mark.parametrize
test all kind of XComFilter

fix unit test parametrize
@wei-juncheng wei-juncheng force-pushed the fix/42720/XCom-Search-on-filter-value-errors branch from 3d6c522 to ff3e8aa Compare February 6, 2025 05:38
@Lee-W Lee-W merged commit f58fb20 into apache:v2-10-test Feb 7, 2025
42 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 7, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants