Airflow web-server raises a werkzeug.routing.BuildError

After cleaning up every airflow-related docker stuff (images, volumes etc) and starting airflow locally using the astro cli, I’m getting the following error:

The full traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.9/site-packages/airflow/www/auth.py", line 51, in decorated
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/airflow/www/views.py", line 730, in index
    return self.render_template(
  File "/usr/local/lib/python3.9/site-packages/airflow/www/views.py", line 502, in render_template
    return super().render_template(
  File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/baseviews.py", line 287, in render_template
    return render_template(
  File "/usr/local/lib/python3.9/site-packages/flask/templating.py", line 137, in render_template
    return _render(
  File "/usr/local/lib/python3.9/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.9/site-packages/airflow/www/templates/airflow/dags.html", line 22, in top-level template code
    {% from 'airflow/_messages.html' import show_message %}
  File "/usr/local/lib/python3.9/site-packages/astronomer/airflow/version_check/templates/astro-baselayout.html", line 1, in top-level template code
    {% extends airflow_base_template %}
  File "/usr/local/lib/python3.9/site-packages/airflow/www/templates/airflow/main.html", line 21, in top-level template code
    {% from 'airflow/_messages.html' import show_message %}
  File "/usr/local/lib/python3.9/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.9/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 37, in top-level template code
    {% block body %}
  File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 19, in block 'body'
    {% block content %}
  File "/usr/local/lib/python3.9/site-packages/airflow/www/templates/airflow/dags.html", line 166, in block 'content'
    <a href="{{ url_for('Airflow.'+ dag.get_default_view(), dag_id=dag.dag_id) }}"
  File "/usr/local/lib/python3.9/site-packages/flask/helpers.py", line 370, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2216, in handle_url_build_error
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/flask/helpers.py", line 357, in url_for
    rv = url_adapter.build(
  File "/usr/local/lib/python3.9/site-packages/werkzeug/routing.py", line 2179, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'Airflow.grid' with values ['dag_id']. Did you mean 'Airflow.graph' instead?

Python version: 3.9.12
Airflow version: 2.2.5+astro.2
Astro CLI Version: 0.28.1, Git Commit: 980c0d7bd06b818a2cb0e948bb101d0b27e3a90a

The error above appears after login in.

1 Like

Hi @sp1thas

Running astrocloud dev kill and then astrocloud dev start again should take care of this. Note that this will purge any variables, connections, metadata etc that were stored in the local postgres instance.

Alternatively if you’d like to avoid using kill, you can try TRUNCATE dag table locally and that should resolve as well.

1 Like

This worked for me as well for local deploys! $ astro dev kill and $ astro dev start