Skip to content

Webserver returns 500 for POST requests to api/dag/*/dagrun from anonymous user  #36110

@eliskovets

Description

@eliskovets

Apache Airflow version

2.7.3

What happened

After upgrade to 2.7.3 I noticed that webserver returns 500 for POST requests with a note field. After some investigation it seems that None in user_id converted to str causing it:

[SQL: INSERT INTO dag_run_note (user_id, dag_run_id, content, created_at, updated_at) VALUES (%(user_id)s, %(dag_run_id)s, %(content)s, %(created_at)s, %(updated_at)s)]
[parameters: {'user_id': 'None', 'dag_run_id': 2944, 'content': 'test', 'created_at': datetime.datetime(2023, 12, 7, 17, 42, 15, 390085, tzinfo=Timezone('UTC')), 'updated_at': datetime.datetime(2023, 12, 7, 17, 42, 15, 390096, tzinfo=Timezone('UTC'))}]
rundag [07/Dec/2023:17:42:15 +0000] "POST /api/v1/dags/*/dagRuns HTTP/1.1" 500 1539 "-" "python-requests/2.31.0"

That's probably not an issue of Airflow itself, but SQLAlchemy 1.4. it's probably fixed in 2.0.

What you think should happen instead

Dagrun should be successfully registered by airflow and note should be saved into dag_run_note table.

How to reproduce

  1. Disable Auth to allow unauthorized access to the API in webserver_config.py
AUTH_ROLE_PUBLIC = "Admin"
  1. Try to schedule a run via DAGRun API
import requests
dag_run_url="https://airflow/api/v1/dags/test/dagRuns"
r = requests.post(
    url=dag_run_url, json={"dag_run_id": "test_me", "note":"note", "conf": {}}
)
assert r.status_code == 500

print(r.text)

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

No response

Deployment

Other Docker-based deployment

Deployment details

Docker image: apache/airflow:2.7.3-python3.9
DB: Postgresql

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions