Repository navigation
Description
Reporting this from the LinkedIn DI Airflow side. The trigger pattern is users inlining very large arguments (whole dataset configs, serialised job parameters, payloads that should live in XCom or external storage) into the Dag run conf when launching Spark / Hadoop jobs. The API returns an opaque 500, the SQL error only shows up in the api-server logs as (1406, "Data too long for column 'conf' at row 1"), and there's no signal to the caller that payload size was the cause. Same class repeats on every length-capped column across the API surface — this issue captures the broader pattern.
What happened
Context: filing this from the LinkedIn Data Infrastructure Airflow / Orchestrator team. We see this in production from users who trigger Spark and Hadoop jobs by inlining very large arguments into the Dag run conf (whole dataset configs, serialised job parameters, payloads that should live in XCom or external storage). The API returns an opaque 500, users retry with the same args, the SQL error only surfaces in the API server logs as (1406, "Data too long for column 'conf' at row 1"), and there's no signal to the caller that payload size was the cause. The same class repeats on every length-capped column across the API surface — this issue captures the broader class.
Across most public REST API and execution API write endpoints, a payload that exceeds the database column's declared type returns a generic 500 Internal Server Error with no actionable signal that payload size was the cause. The underlying sqlalchemy.exc.DataError (MySQL 1406 Data too long, MySQL 1264 Out of range, Postgres value too long for type ..., Postgres numeric field overflow) is wrapped into the generic 500 handler instead of being translated into a 4xx with the column name + remediation. The same failure shape repeats on every length-capped column in the metadata DB.
#66779 reported this for DagRun.conf specifically; this issue captures the broader class so it can be closed by a small set of related PRs instead of one boundary patch per column.
Affected on the public REST API: POST/PATCH /dags/{id}/dagRuns (conf, note), PATCH /dagRuns/{run_id} (note), PATCH /dags/{id} (description, timetable_summary), POST/PATCH /connections (extra, login, password), POST/PATCH /variables (val, description), POST/PATCH /pools (description, slots overflow), POST /xcoms (value), PATCH /taskInstances/{ti_id} (note, rendered_map_index), POST /backfills (dag_run_conf), POST /assets/events (extra), and HITL endpoints (subject, body, options, params).
Affected on the execution API: PATCH /task-instances/{id}/run (hostname, unixname, next_method), PATCH /task-instances/{id}/state (note, rendered_map_index, external_executor_id), POST /xcoms/{id} (value), PUT /assets/events (extra).
Any future write endpoint that touches a length-capped column has the same exposure today — there is no central translation, so each new column relies on its caller knowing the DB schema's caps.
Proposed fix — two stacked PRs
#66888 registers a global DataError → 413/422 handler on both FastAPI apps. Data too long / too large / too big map to 413 Content Too Large; out-of-range / numeric overflow maps to 422 Unprocessable Entity. Every existing and future route inherits the translation.
#66890 fixes three local catches in the execution API's task_instances.py that today swallow DataError before the global handler can see it. Two of them re-raise as opaque 500; the third (in ti_update_state) reroutes into a "silently mark TI FAILED + return 204" branch — which is worse than an opaque 500 because the worker has no signal the state update was actually rejected.
Safe to merge in either order — each PR is useful on its own.
How to reproduce
Real MySQL DataError, then HTTP responses across multiple endpoints driven through the real Airflow create_app() via TestClient.
docker run --rm -d --name mysql-66889 -e MYSQL_ROOT_PASSWORD=test \
-e MYSQL_DATABASE=airflow_test -p 3309:3306 mysql:8.0import json
from sqlalchemy import create_engine, text
engine = create_engine("mysql+pymysql://root:[email protected]:3309/airflow_test")
with engine.begin() as c:
c.execute(text("CREATE TABLE dag_run (id INT PRIMARY KEY AUTO_INCREMENT, conf TEXT) ENGINE=InnoDB"))
c.execute(text("INSERT INTO dag_run (conf) VALUES (:c)"), {"c": json.dumps({"k": "x"*70000})})
# sqlalchemy.exc.DataError: (pymysql.err.DataError) (1406, "Data too long for column 'conf' at row 1")Then drive five real public-REST routes via TestClient(create_app()) with Session.flush/Session.commit monkey-patched to raise that same DataError. On main every endpoint returns 500 Internal Server Error. With #66888 applied, every endpoint returns 413 Content Too Large with the structured detail body:
POST /dags/{id}/dagRuns conf 500 -> 413
POST /connections extra 500 -> 413
POST /variables val 500 -> 413
POST /pools description 500 -> 413
POST /assets/events extra 500 -> 413
For PATCH /task-instances/{id}/state on the execution API, the transition needs both PRs because of the local except Exception: at line 425. Three states:
BEFORE (upstream/main) HTTP 204 + TI silently marked FAILED
MIDDLE (only #66888) HTTP 204 + TI silently marked FAILED
AFTER (#66888 + #66890) HTTP 413 with structured body; TI keeps original state
The MIDDLE state is the load-bearing evidence — it shows #66888 alone is not enough for the task-instance state endpoint.
Tests
airflow-core/tests/unit/api_fastapi/common/test_exceptions.py::TestDataErrorHandler (in #66888) covers five dialect-error shapes plus an end-to-end FastAPI dispatch test:
TestDataErrorHandler::test_dataerror_translates_to_actionable_http_response[mysql-1406-data-too-long] PASSED
TestDataErrorHandler::test_dataerror_translates_to_actionable_http_response[postgres-value-too-long] PASSED
TestDataErrorHandler::test_dataerror_translates_to_actionable_http_response[sqlite-blob-too-big] PASSED
TestDataErrorHandler::test_dataerror_translates_to_actionable_http_response[mysql-1264-out-of-range] PASSED
TestDataErrorHandler::test_dataerror_translates_to_actionable_http_response[postgres-numeric-field-overflow] PASSED
TestDataErrorHandler::test_dataerror_dispatched_through_fastapi_app PASSED
Out of scope
IntegrityError (FK / NOT NULL violations beyond the unique-constraint case _UniqueConstraintErrorHandler already handles) has different response semantics. Natural follow-up if maintainers like this DataError shape.
Operating System
Reproduced on Linux / macOS against MySQL 8.0 in Docker. Backend-agnostic — Postgres produces a different verbatim message but the same SQLAlchemy DataError class.
Versions of Apache Airflow Providers
n/a — API server / metadata DB path.
Deployment
Other Docker-based
Deployment details
MySQL 8.0 default innodb_default_row_format with TEXT-typed columns. Postgres avoids the 1406 family but hits the same DataError shape on VARCHAR(N) overruns and numeric overflows.
Anything else?
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Activity
[-]Translate sqlalchemy.exc.DataError to actionable 4xx across REST + execution API[/-][+]API write endpoints return opaque 500 when the database rejects a payload[/+]1fanwang commentedon May 18, 2026
#66888 + #66890 carry the fix end-to-end across the affected REST and execution-API routes. Closing this umbrella so the discussion converges on the two PRs.