Issue 1:
Apache Airflow version: 2.0.0

Environment: Docker image apache/airflow:2.0.0-python3.8 on Win10 with WSL

What happened:

I built a custom provider with a number of custom connections.

This works:

The connections are properly registered

The UI does not show hidden fields as per get_ui_field_behaviour

The UI correctly relabels fields as per get_ui_field_behaviour

The UI correctly shows added widgets as per get_connection_form_widgets (well, mostly)

What does not work:

The UI does not save values entered for additional widgets

I used the JDBC example to string myself along by copying it and pasting it as a hook into my custom provider package. (I did not install the JDBC provider package, unless it is installed in the image I use - but if I don't add it in my own provider package, I don't have the connection type in the UI, so I assume it is not). Curiously, The JDBC hook works just fine. I then created the following file:

"""
You find two child classes of DbApiHook in here. One is the exact copy of the JDBC
provider hook, minus some irrelevant logic (I only care about the UI stuff here).
The other is the exact same thing, except I added an "x" behind every occurance
of "jdbc" in strings and names.
"""

from typing import Any, Dict, Optional
from airflow.hooks.dbapi import DbApiHook

class JdbcXHook(DbApiHook):
"""
Copy of JdbcHook below. Added an "x" at various places, including the class name.
"""

conn_name_attr = 'jdbcx_conn_id' # added x
default_conn_name = 'jdbcx_default' # added x
conn_type = 'jdbcx' # added x
hook_name = 'JDBCx Connection' # added x
supports_autocommit = True

@staticmethod
def get_connection_form_widgets() -> Dict[str, Any]:
"""Returns connection widgets to add to connection form"""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField

# added an x in the keys
return {
"extra__jdbcx__drv_path": StringField(lazy_gettext('Driver Path'), widget=BS3TextFieldWidget()),
"extra__jdbcx__drv_clsname": StringField(
lazy_gettext('Driver Class'), widget=BS3TextFieldWidget()
),
}

@staticmethod
def get_ui_field_behaviour() -> Dict:
"""Returns custom field behaviour"""
return {
"hidden_fields": ['port', 'schema', 'extra'],
"relabeling": {'host': 'Connection URL'},
}

class JdbcHook(DbApiHook):
"""
General hook for jdbc db access.
JDBC URL, username and password will be taken from the predefined connection.
Note that the whole JDBC URL must be specified in the "host" field in the DB.
Raises an airflow error if the given connection id doesn't exist.
"""

conn_name_attr = 'jdbc_conn_id'
default_conn_name = 'jdbc_default'
conn_type = 'jdbc'
hook_name = 'JDBC Connection plain'
supports_autocommit = True

@staticmethod
def get_connection_form_widgets() -> Dict[str, Any]:
"""Returns connection widgets to add to connection form"""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField

return {
"extra__jdbc__drv_path": StringField(lazy_gettext('Driver Path'), widget=BS3TextFieldWidget()),
"extra__jdbc__drv_clsname": StringField(
lazy_gettext('Driver Class'), widget=BS3TextFieldWidget()
),
}

@staticmethod
def get_ui_field_behaviour() -> Dict:
"""Returns custom field behaviour"""
return {
"hidden_fields": ['port', 'schema', 'extra'],
"relabeling": {'host': 'Connection URL'},
}

What you expected to happen:

After doing the above, I expected

Seeing both in the add connection UI

Being able to use both the same way

What actually happenes:

I do see both in the UI (Screenshot 1)

For some reason, the "normal" hook has BOTH extra fields - not just his own two? (Screenshot 2)

If I add the connection as in Screenshot 2, they are saved in the four fields (his own two + the two for the "x" hook) properly as shown in Screenshot 3

If I seek to edit the connection again, they are also they - all four fields - with the correct values in the UI

If I add the connection for the "x" type as in Screenshot 4, it ostensibly saves it - with two fields as defined in the code

You can see in screenshot 5, that the extra is saved as an empty string?!

When trying to edit the connection in the UI, you also see that there is no data saved for two extra widgets?!

I added a few more screenshots of airflow providers CLI command results (note that the package ewah has a number of other custom hooks, and the issue above occurs for all of them)

Screenshot 1:

Screenshot 2:

Screenshot 3:

Screenshot 4:

Screenshot 5:

Screenshot 6 - airflow providers behaviours:

Screenshot 7 - airflow providers get:

(Note: This error occurs with pre-installed providers as well)

Screenshot 8 - airflow providers hooks:

Screenshot 9 - aorflow providers list:

Screenshot 10 - airflow providers widgets:

How to reproduce it:

create a custom provider package

add the code snippet pasted above somewhere

add the two classes to the hook-class-names list in the provider info

install the provider package

do what I described above

Issue 2:
Apache Airflow version

2.1.3 (latest released)

Operating System

Debian GNU/Linux 10 (buster)

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==2.1.0

apache-airflow-providers-celery==2.0.0

apache-airflow-providers-cncf-kubernetes==2.0.2

apache-airflow-providers-docker==2.1.0

apache-airflow-providers-elasticsearch==2.0.2

apache-airflow-providers-ftp==2.0.0

apache-airflow-providers-google==5.0.0

apache-airflow-providers-grpc==2.0.0

apache-airflow-providers-hashicorp==2.0.0

apache-airflow-providers-http==2.0.0

apache-airflow-providers-imap==2.0.0

apache-airflow-providers-microsoft-azure==3.1.0

apache-airflow-providers-mysql==2.1.0

apache-airflow-providers-postgres==2.0.0

apache-airflow-providers-redis==2.0.0

apache-airflow-providers-sendgrid==2.0.0

apache-airflow-providers-sftp==2.1.0

apache-airflow-providers-slack==4.0.0

apache-airflow-providers-sqlite==2.0.0

apache-airflow-providers-ssh==2.1.0

Deployment

Other Docker-based deployment

Deployment details

Base docker image- apache/airflow:2.1.3-python3.7

What happened

Last Runs for the DAGs on the listing page are not loading because the /last_dagruns endpoint is returning 500 error.

What you expected to happen

The Last Run for the DAGs should show the latest execution date of each DAG

How to reproduce

Open the DAG listing page

Look at the Last Run column, which would continuously show the loader for each DAG

If you open the Network, you would observe a 500 error for /last_dagruns endpoint

Anything else

No response

Are you willing to submit PR?

Yes I am willing to submit a PR!

Code of Conduct

I agree to follow this project's Code of Conduct