Skip to content

Conversation

@xuganyu96
Copy link
Contributor

@xuganyu96 xuganyu96 commented Jul 5, 2023

This PR is related to the following issues and PRs: #32287, #28777, #32288, #28772.

Previous efforts related to JSON-serializing DagRun configuration have provided an elegant solution in the form of a custom JSON encoder class named WebEncoder, which is used to encode non-JSON serializable objects stored in DagRun.conf. This allows DAG run conf to be correctly rendered in the grid view, but the fix was not applied to the list view, hence breaking /dagrun/list if there are conf values that are not JSON serializable.

This PR attempts to address the incompleteness of the previous fix by using WebEncoder in formatters_columns, which should allow non-JSON-serializable conf to be rendered in list view in the same way it is rendered in grid view.

Note that www.utils.json_f is used exactly once where the code change happened, and the code change seems trivial, so I am not sure if unit tests or other forms of validation is warranted, but I am happy to write tests if necessary.

Thank you for considering my contribution!


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 Jul 5, 2023
Copy link
Member

Choose a reason for hiding this comment

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

I think we should always use WebEncoder here, so the extra argument is not needed.

Right now json_f is actually only used once, but since json_f is only for the web UI, all usages in the future should use WebEncoder anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally speaking I've typically found it easier to keep parameterization open since it's more flexible and we should probably not be so sure about future usage of json_f, but I am open to suggestions. Maybe we can wait for a second opinion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@uranusjr I've updated the code so that json_f always uses WebEncoder and updated the relevant func calls + unit tests. Please review at your convenience. Thank you!

@xuganyu96 xuganyu96 force-pushed the dagrun-list-view-conf-serialization branch from c97c90f to b30d0c6 Compare July 6, 2023 17:17
@potiuk
Copy link
Member

potiuk commented Jul 6, 2023

@uranusjr ? I think that might be a good candidate to add to 2.6.3

@ephraimbuddy ephraimbuddy merged commit 4bbb633 into apache:main Jul 7, 2023
ephraimbuddy pushed a commit that referenced this pull request Jul 7, 2023
* Use WebEncoder to encode DagRun.conf in DagRun's list view

* test case for json_f with WebEncoder

* Always use WebEncoder in web views

(cherry picked from commit 4bbb633)
@ephraimbuddy ephraimbuddy added this to the Airflow 2.6.3 milestone Jul 7, 2023
syedahsn pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jul 11, 2023
)

* Use WebEncoder to encode DagRun.conf in DagRun's list view

* test case for json_f with WebEncoder

* Always use WebEncoder in web views
@xuganyu96 xuganyu96 deleted the dagrun-list-view-conf-serialization branch July 16, 2023 03:31
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Aug 2, 2023
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