Skip to content

Conversation

@luoyuliuyin
Copy link
Contributor

Apache Airflow version

main (development)

How to reproduce

POST request with content-type as application/json; charset=utf-8

curl -X 'PATCH' \
  'https://you_host_com/api/v1/dags/dag_id/dagRuns/run_id' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -d '{
  "state": "success"
}'

Problem Description

When an API call is made, if the API has the @action_logging annotation, the event will be recorded in the db log table as follows
image

Related Code

Currently, whether the current request contains json_body is determined by judging whether request.headers.get("content-type") is equal to application/json. The relevant code is as follows
image

But in many cases, the content-type contains other information besides application/json, such as application/json; charset=utf-8. In this case, the database will not record valid information.
image

Solution

So the judgment condition should be changed to include

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:webserver Webserver related Issues labels Jan 10, 2025
pierrejeambrun
pierrejeambrun previously approved these changes Jan 10, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Nice catch

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

NIce.

Small nits before merging, but looking good.

@pierrejeambrun pierrejeambrun added the type:bug-fix Changelog: Bug Fixes label Jan 10, 2025
@luoyuliuyin
Copy link
Contributor Author

NIce.

Small nits before merging, but looking good.

Thank you for the suggestion. Please check the latest commit.

@pierrejeambrun pierrejeambrun merged commit bae4bb1 into apache:main Jan 10, 2025
7 checks passed
@github-actions
Copy link

Backport failed to create: v2-10-test. View the failure log Run details

Status Branch Result
v2-10-test Commit Link

You can attempt to backport this manually by running:

cherry_picker bae4bb1 v2-10-test

This should apply the commit to the v2-10-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

pierrejeambrun pushed a commit to astronomer/airflow that referenced this pull request Jan 10, 2025
@pierrejeambrun
Copy link
Member

cherry pick PR here:
#45560

ashb added a commit that referenced this pull request Jan 10, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
potiuk pushed a commit that referenced this pull request Jan 10, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
potiuk pushed a commit that referenced this pull request Jan 13, 2025
* fix: log action get the correct request body (#45546)

(cherry picked from commit bae4bb1)

* Fix log_action decorator when content type is None (#45567)

(cherry picked from commit 46304d8)

---------

Co-authored-by: luoyuliuyin <luoyuliuyin@gmail.com>
Co-authored-by: Daniel Standish <15932138+dstandish@users.noreply.github.com>
karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jan 13, 2025
karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jan 13, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
HariGS-DB pushed a commit to HariGS-DB/airflow that referenced this pull request Jan 16, 2025
HariGS-DB pushed a commit to HariGS-DB/airflow that referenced this pull request Jan 16, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
dauinh pushed a commit to dauinh/airflow that referenced this pull request Jan 24, 2025
dauinh pushed a commit to dauinh/airflow that referenced this pull request Jan 24, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
This was merged without letting tests pass somehow. We have removed the
`root_dag` argument in Airflow 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants