Skip to content

Make conn_type optional in task SDK Connection datamodel#61728

Merged
amoghrajesh merged 1 commit into
apache:mainfrom
astronomer:conn-type-optional-sdk
Feb 11, 2026
Merged

Make conn_type optional in task SDK Connection datamodel#61728
amoghrajesh merged 1 commit into
apache:mainfrom
astronomer:conn-type-optional-sdk

Conversation

@amoghrajesh
Copy link
Copy Markdown
Contributor

@amoghrajesh amoghrajesh commented Feb 10, 2026


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

closes: #58529

Why?

When workers retrieve connections from secrets backends like AWS Secrets Manager that don't include conn_type, the Connection.from_json() method fails during deserialization with error:

TypeError: Connection.__init__() missing 1 required keyword-only argument: 'conn_type'

Simple test to show an example for this:

(apache-airflow) ➜  airflow git:(conn-type-optional-sdk) ✗ cat > /tmp/test_connections.json << 'EOF'
{
  "my_db": {
    "host": "mydb.us-east-1.rds.amazonaws.com",
    "port": 5432,
    "login": "admin",
    "password": "secret123",
    "schema": "production"
  }
}
EOF

Before:

>>> import json
>>> json_from_aws = json.dumps({
...     "host": "mydb.us-east-1.rds.amazonaws.com",
...     "port": 5432,
...     "login": "admin",
...     "password": "secret123",
...     "schema": "production"
... })
>>> 
>>> from airflow.sdk import Connection
>>> conn = Connection.from_json(json_from_aws, conn_id="my_db")
Traceback (most recent call last):
  File "<python-input-10>", line 1, in <module>
    conn = Connection.from_json(json_from_aws, conn_id="my_db")
  File "/Users/amoghdesai/Documents/OSS/repos/airflow/task-sdk/src/airflow/sdk/definitions/connection.py", line 307, in from_json
    return cls(conn_id=conn_id, **kwargs)
TypeError: Connection.__init__() missing 1 required positional argument: 'conn_type'

After:

>>> import json
>>> from airflow.sdk import Connection
>>> 
>>> json_from_aws = json.dumps({
...     "host": "mydb.us-east-1.rds.amazonaws.com",
...     "port": 5432,
...     "login": "admin",
...     "password": "secret123",
...     "schema": "production"
... })
>>> conn = Connection.from_json(json_from_aws, conn_id="my_db")
>>> conn
Connection(conn_id='my_db', conn_type=None, description=None, host='mydb.us-east-1.rds.amazonaws.com', schema='production', login='admin', password='secret123', port=5432, extra=None)

What

Making conn_type optional in task SDK Connection datamodel to restore backward compatibility with Airflow 2 for connections stored in secrets backends without conn_type.

For example: connections in AWS Secrets Manager (and other external secrets backends) fail to load on workers when conn_type field is missing and that breaks compat with Airflow 3 for certain providers.

This will later block users migrating from Airflow 2 to Airflow 3 who have hundreds/thousands of secrets stored without conn_type (which worked fine in Airflow 2).

Solution

Make conn_type optional in task SDK Connection class. Let me explain why this is safe.

  1. Secrets backends run only on workers - connections without conn_type exist only in worker context, never sent via Execution API
  2. The responses that are sent by the API server always has conn_type - connections from database always have conn_type (NOT NULL column), so execution API ConnectionResponse doesn't need changes at all (cadwyn migration etc)

For testing, I have added one scenario that would break earlier but doesn't anymore.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

Comment thread task-sdk/src/airflow/sdk/definitions/connection.py
@amoghrajesh amoghrajesh requested a review from Lee-W February 11, 2026 08:41
@amoghrajesh amoghrajesh merged commit a6e6c28 into apache:main Feb 11, 2026
101 checks passed
@amoghrajesh amoghrajesh deleted the conn-type-optional-sdk branch February 11, 2026 16:55
@amoghrajesh
Copy link
Copy Markdown
Contributor Author

Actually this is a bug fix, which we can get into 3.1.8 as well

amoghrajesh added a commit that referenced this pull request Feb 13, 2026
…61728)

(cherry picked from commit a6e6c28)

Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
vatsrahul1001 pushed a commit that referenced this pull request Feb 13, 2026
Ratasa143 pushed a commit to Ratasa143/airflow that referenced this pull request Feb 15, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
vatsrahul1001 pushed a commit that referenced this pull request Mar 4, 2026
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate option for execution API Connections datamodel for connections with no conn_type

6 participants