Skip to content

Refactor: Replace generic AirflowException with specific built-in exceptions in connection.py and helpers.py #71122

Description

@KushagraB424

Description

The Airflow contributor guidelines explicitly state that we should reduce the usage of the generic AirflowException in favor of more specific Python built-ins. I noticed a few places where AirflowException is currently being used improperly and should be replaced:

  • In airflow/models/connection.py, invalid connection strings raise AirflowException. These should be updated to ValueError.
  • In airflow/utils/helpers.py, string length limits and timeouts raise AirflowException. These should be updated to ValueError and TimeoutError.

I will be opening a PR for this shortly!

Use case/motivation

Improving codebase quality and adhering to the community's current coding standards by using specific exceptions (like ValueError and TimeoutError). This makes error handling and debugging clearer for users and contributors, rather than catching a broad AirflowException.

Related issues

None

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions