Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking Edit on TaskInstance Causes Crash #12489

Closed
jrd281 opened this issue Nov 19, 2020 · 10 comments · Fixed by #12770
Closed

Clicking Edit on TaskInstance Causes Crash #12489

jrd281 opened this issue Nov 19, 2020 · 10 comments · Fixed by #12770
Assignees
Labels
affected_version:2.0 Issues Reported for 2.0 area:webserver Webserver related Issues kind:bug This is a clearly a bug

Comments

@jrd281
Copy link

jrd281 commented Nov 19, 2020

Apache Airflow version: 2.0.0b2

Kubernetes version (if you are using kubernetes) (use kubectl version): N/A

Environment:

What happened: I was looking at the taskinstance list and then I clicked the edit icon. After clicking, an error page was displayed.

What you expected to happen: I expected to be whisked to an editing UI

How to reproduce it:

  1. Visit your installation's home page
  2. Click the success bucket under the Recent Tasks heading
    AirflowDebug#1
  3. Click the Edit button for one of your tasks
    AirflowDebug#2
  4. Watch the system throw an error.
    AirflowDebug#3

Anything else we need to know:

UI Error Page Something bad has happened. Please consider letting us know by creating a bug report using GitHub.

Python version: 3.8.5
Airflow version: 2.0.0b2
Node: REDACTED

Traceback (most recent call last):
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
return f(self, *args, **kwargs)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/views.py", line 606, in edit
return self.render_template(
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/baseviews.py", line 280, in render_template
return render_template(
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 2, in top-level template code
{% import 'appbuilder/general/lib.html' as lib %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/base.html", line 1, in top-level template code
{% extends base_template %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/airflow/www/templates/airflow/master.html", line 20, in top-level template code
{% extends 'appbuilder/baselayout.html' %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 2, in top-level template code
{% import 'appbuilder/baselib.html' as baselib %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 46, in top-level template code
{% block body %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 19, in block "body"
{% block content %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 23, in block "content"
{% block edit_form %}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 25, in block "edit_form"
{{ widgets.get('edit')(form_action=form_action)|safe }}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/widgets.py", line 37, in call
return template.render(args)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/widgets/form.html", line 45, in top-level template code
{{ lib.render_field(field, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/jinja2/runtime.py", line 679, in _invoke
rv = self._func(*arguments)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/lib.html", line 237, in template
{{ field(**kwargs)|safe }}
File "/var/lib/airflow/venv/lib/python3.8/site-packages/wtforms/fields/core.py", line 160, in call
return self.meta.render_field(self, kwargs)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/wtforms/meta.py", line 56, in render_field
return field.widget(field, **render_kw)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/fieldwidgets.py", line 176, in call
return super(Select2ManyWidget, self).call(field, **kwargs)
File "/var/lib/airflow/venv/lib/python3.8/site-packages/wtforms/widgets/core.py", line 300, in call
for val, label, selected in field.iter_choices():
File "/var/lib/airflow/venv/lib/python3.8/site-packages/flask_appbuilder/fields.py", line 209, in iter_choices
yield (pk, self.get_label(obj), obj in self.data)
TypeError: argument of type 'DagRun' is not iterable

How often does this problem occur?: Every time I click the Edit icon

@jrd281 jrd281 added the kind:bug This is a clearly a bug label Nov 19, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 19, 2020

Thanks for opening your first issue here! Be sure to follow the issue template!

@zachliu
Copy link
Contributor

zachliu commented Nov 19, 2020

@jrd281 lol, you beat me to it 😂
let me add that this 🐛 is also in 2.0.0b3

Something bad has happened.
Please consider letting us know by creating a bug report using GitHub.

Python version: 3.8.6
Airflow version: 2.0.0b3
Node: <Of Course I Still Love You>
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/views.py", line 606, in edit
    return self.render_template(
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/baseviews.py", line 280, in render_template
    return render_template(
  File "/usr/local/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
    return _render(
  File "/usr/local/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 2, in top-level template code
    {% import 'appbuilder/general/lib.html' as lib %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/base.html", line 1, in top-level template code
    {% extends base_template %}
  File "/usr/local/lib/python3.8/site-packages/airflow/www/templates/airflow/master.html", line 20, in top-level template code
    {% extends 'appbuilder/baselayout.html' %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 2, in top-level template code
    {% import 'appbuilder/baselib.html' as baselib %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 46, in top-level template code
    {% block body %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 19, in block "body"
    {% block content %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 23, in block "content"
    {% block edit_form %}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/model/edit.html", line 25, in block "edit_form"
    {{ widgets.get('edit')(form_action=form_action)|safe }}
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/widgets.py", line 37, in __call__
    return template.render(args)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/widgets/form.html", line 45, in top-level template code
    {{ lib.render_field(field, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
  File "/usr/local/lib/python3.8/site-packages/jinja2/runtime.py", line 679, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/general/lib.html", line 237, in template
    {{ field(**kwargs)|safe }}
  File "/usr/local/lib/python3.8/site-packages/wtforms/fields/core.py", line 160, in __call__
    return self.meta.render_field(self, kwargs)
  File "/usr/local/lib/python3.8/site-packages/wtforms/meta.py", line 56, in render_field
    return field.widget(field, **render_kw)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/fieldwidgets.py", line 176, in __call__
    return super(Select2ManyWidget, self).__call__(field, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/wtforms/widgets/core.py", line 300, in __call__
    for val, label, selected in field.iter_choices():
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/fields.py", line 209, in iter_choices
    yield (pk, self.get_label(obj), obj in self.data)
TypeError: argument of type 'DagRun' is not iterable

@mik-laj mik-laj added the area:webserver Webserver related Issues label Nov 20, 2020
@patchandpray
Copy link
Contributor

I'd like to work on this one.

@mik-laj
Copy link
Member

mik-laj commented Nov 20, 2020

@patchandpray Assigned 🐈

@ryw
Copy link
Member

ryw commented Nov 30, 2020

any progress on this @patchandpray?

@patchandpray
Copy link
Contributor

I managed to identify where the problem is. but I did not have the time to look into the actual fix. I should have time for that tomorrow :)

@ryw
Copy link
Member

ryw commented Dec 2, 2020

ok we'd like this bugfix in for Airflow 2.0rc1 so let us know if you get stuck / need help

@patchandpray
Copy link
Contributor

Hi, I think I need some help.

I have been able to deduce that the issue arises upon form autogeneration for a taskinstance by flask-appbuilder. When editing a taskinstance. A taskinstance appears to have a one on one relationship with a DagRun and when generating the edit form flask_appbuilder uses QuerySelectMultipleField.iter_choices() which gets called with: <DagRun example_bash_operator @ 2020-11-29 00:00:00+00:00: scheduled__2020-11-29T00:00:00+00:00, externally triggered: False>. Since this is a non-iterable object the exception is raised.

When using QuerySelectField.iter_choices() with this object the form does generate but I am stuck finding a way to force this behavior from airflow code. An option might be to not autogenerate a form and specify a form for taskinstance edit so we can explicitly define which fields to use but I am unsure if this is the correct way to implement a fix for this.

Also, how is determined which fields are generated for this form?

Furthermore when forcing the generation from flask_appbuilder and generating a form:
image

when trying to save a modification for a taskinstance I am presented with this error. I want to create a new bug report for this but it might be related to this bug.
image

@kaxil
Copy link
Member

kaxil commented Dec 3, 2020

@patchandpray #12770 fixes the issue.

We are in process of fixing all the pending bugs for 2.0 since we are just a week away from cutting RCs -- so I went ahead and created the PR to fix this.

@patchandpray
Copy link
Contributor

I understand completely. 🙂

@vikramkoka vikramkoka added the affected_version:2.0 Issues Reported for 2.0 label Dec 4, 2020
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 15, 2021
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 17, 2021
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 23, 2021
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Nov 27, 2021
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Mar 10, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jun 4, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jun 7, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jul 9, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Aug 27, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Oct 4, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
aglipska pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Oct 7, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Dec 7, 2022
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jan 27, 2023
…770)

closes apache/airflow#12489

GitOrigin-RevId: be7d867459dcc4d26bd3cae55df6ff118c2be16a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected_version:2.0 Issues Reported for 2.0 area:webserver Webserver related Issues kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants