Skip to content

IBM Db2 provider: skip None-valued extra parameters to avoid KEY=None in connection strings - #72025

Open
ShubhamKapoor992 wants to merge 1 commit into
apache:mainfrom
ShubhamKapoor992:db2-provider-test-connection
Open

IBM Db2 provider: skip None-valued extra parameters to avoid KEY=None in connection strings#72025
ShubhamKapoor992 wants to merge 1 commit into
apache:mainfrom
ShubhamKapoor992:db2-provider-test-connection

Conversation

@ShubhamKapoor992

Copy link
Copy Markdown

Description

Skip None-valued extra parameters when building Db2 connection strings and URIs

When extra connection parameters contain keys with None values (e.g. from a partially-filled connection form), the previous code would emit them as the literal string "None" in the Db2 connection string (KEY=None;) and in the SQLAlchemy URI query string (?KEY=None). Both cases result in either a connection error or silently passing a bad value to the driver.

This fix skips None-valued keys in both get_conn() (connection string builder) and get_uri() (SQLAlchemy URI builder), so only explicitly configured parameters reach the Db2 driver.


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

  • 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, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Note: The change is small and self-contained and the provider isn't released nor used so I have not created the Git Issue.

@boring-cyborg

boring-cyborg Bot commented Aug 24, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@ColtenOuO ColtenOuO left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix -- skipping None-valued extras in get_conn()/get_uri() looks correct and avoids emitting KEY=None to the Db2 driver.

I think there have a few things before this is ready to merge:

  1. The PR title should clearly describe the specific changes rather than just mentioning which provider were modified.
  2. I think we need to add a test to prevent the same issue from happening again in the future.
  3. To keep the branch clean, we should rebase onto main instead of merging.
  4. Similar to the PR title, commit messages should explain the reasoning and the solution behind the changes in detail, so that future contributors touching similar files can quickly understand the context.

… in connection strings

When a user leaves an optional extra field blank in the Airflow connection
form, the JSON stored in the extra field contains null values (e.g.
{"SSLServerCertificate": null}). Previously these were emitted verbatim
into both the ibm_db connection string (KEY=None;) and the SQLAlchemy URI
query string (?KEY=None), causing the Db2 driver to receive the literal
string "None" as a parameter value. This either triggers a connection
error or silently passes a bad value to the driver.

Fix: skip any extra key whose value is None before building the connection
string in get_conn() and before building the query string in get_uri().

Add parametrized tests covering both methods to prevent regression.
@ShubhamKapoor992
ShubhamKapoor992 force-pushed the db2-provider-test-connection branch from 183dc44 to dc9895f Compare August 24, 2026 14:26
@ShubhamKapoor992 ShubhamKapoor992 changed the title Changes for test connection in db2 provider IBM Db2 provider: skip None-valued extra parameters to avoid KEY=None in connection strings Aug 24, 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.

2 participants