Skip to content

Sorting by Note in List Dag Run fails #30041

Description

@mayeulk

Apache Airflow version

2.5.1

What happened

Going to Airflow web UI, Browse>DAG Run displays the list of runs:
http://0.0.0.0:8084/dagrun/list/
Clicking on the columns headers allow to sort the data, except for the 'Note' field. This opens
http://0.0.0.0:8084/dagrun/list/?_oc_DagRunModelView=note&_od_DagRunModelView=asc
and displays an error page:
" Ooops!
Something bad has happened.
...
Python version: 3.7.16
Airflow version: 2.5.1
Node: 80277a0dd39e


Error! Please contact server admin."

What you think should happen instead

It should sort the data by Note.

How to reproduce

Run the docker stack. Click Browse>DAG Run to display the list of runs. Then click on the "Note" column header.

Operating System

Docker image "FROM apache/airflow:2.5.1-python3.7" (with Ubuntu host)

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

Following https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html
Docker file is:
#!/usr/bin/env -S docker build . --tag=airflow_python_r_v1 --network=host --file

ARG AIRFLOW_VERSION=2.5.1
ARG PYTHON_RUNTIME_VERSION=3.7
FROM apache/airflow:${AIRFLOW_VERSION}-python${PYTHON_RUNTIME_VERSION}
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
USER root

ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

USER airflow

Anything else

Logs form the airflow-webserver container:

127.0.0.1 - - [11/Mar/2023:14:58:11 +0100] "GET /health HTTP/1.1" 200 141 "-" "curl/7.74.0"
[2023-03-11 14:58:17,322] {app.py:1742} ERROR - Exception on /dagrun/list/ [GET]
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/security/decorators.py", line 133, in wraps
    return f(self, *args, **kwargs)
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/views.py", line 554, in list
    widgets = self._list()
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/baseviews.py", line 1169, in _list
    page_size=page_size,
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/baseviews.py", line 1068, in _get_list_widget
    page_size=page_size,
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/models/sqla/interface.py", line 469, in query
    select_columns,
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/models/sqla/interface.py", line 424, in apply_all
    aliases_mapping=aliases_mapping,
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/models/sqla/interface.py", line 371, in _apply_inner_all
    query, order_column, order_direction, aliases_mapping=aliases_mapping
  File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/models/sqla/interface.py", line 207, in apply_order_by
    query = query.order_by(asc(_order_column))
  File "<string>", line 2, in asc
  File "/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 3599, in _create_asc
    coercions.expect(roles.ByOfRole, column),
  File "/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/sql/coercions.py", line 177, in expect
    element = element.__clause_element__()
  File "/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/ext/associationproxy.py", line 442, in __clause_element__
    "The association proxy can't be used as a plain column "
NotImplementedError: The association proxy can't be used as a plain column expression; it only works inside of a comparison expression
172.31.0.1 - - [11/Mar/2023:14:58:17 +0100] "GET /dagrun/list/?_oc_DagRunModelView=note&_od_DagRunModelView=asc HTTP/1.1" 500 1544 "http://0.0.0.0:8084/dagrun/list/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0"
127.0.0.1 - - [11/Mar/2023:14:58:42 +0100] "GET /health HTTP/1.1" 200 141 "-" "curl/7.74.0"

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