REST API array of strings #66201
-
|
I'm trying to figure out how to use arrays in the rest interface. Specifically I want to get dags that are failed or queued. According to the REST documentation state can be an array of strings, but I'm not sure how to actually format that In airflow 2 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
@johnhoran In Airflow 3, The old Airflow 2 form: So for Airflow 3 API v2, please use repeated implemantation(airflow-core/src/airflow/api_fastapi/common/parameters.py:1143)def _transform_dag_run_states(states: Iterable[str] | None) -> list[DagRunState | None] | None:
try:
if not states:
return None
return [None if s in ("none", None) else DagRunState(s) for s in states]
except ValueError:
raise HTTPException(
status_code=HTTP_422_UNPROCESSABLE_CONTENT,
detail=f"Invalid value for state. Valid values are {', '.join(DagRunState)}",
) |
Beta Was this translation helpful? Give feedback.
@johnhoran
Thanks for the report. This is a behavior change between the Airflow 2
/api/v1endpoint and the Airflow 3/api/v2endpoint.In Airflow 3,
stateis handled as an array query parameter. Multiple values should be sent by repeating the query parameter, for example:/api/v2/dags/~/dagRuns?state=failed&state=queuedThe old Airflow 2 form:
/api/v2/dags/~/dagRuns?state=failed%2Cqueuedis decoded as a single value,failed,queued, and then rejected because it is not one of the valid individual DagRun states:queued,running,success, orfailed.So for Airflow 3 API v2, please use repeated
stateparameters instead of a comma-separated value.state=failed&state=queuednotstate=failed%2Cqu…