Enable detection of errors in Variable.get() such as absence of key method and connection failure to Metastore #39577
Labels
kind:feature
Feature Requests
needs-triage
label for new issues that we didn't triage yet
pending-response
stale
Stale PRs per the .github/workflows/stale.yml policy file
Description
When attempting to retrieve a value by specifying a key using the Variable.get() method, there are cases where the retrieval fails, such as:
However, in the current implementation of Airflow, all exception handling is being suppressed in the following part, making it impossible for users to differentiate these cases:
airflow/airflow/models/variable.py
Lines 286 to 291 in defe459
I believe that Variable.get() should return None if the specified key does not exist, and it should raise an exception for unexpected errors such as connection errors.
Use case/motivation
With this feature, it becomes possible to handle errors specific to each cause as follows:
Related issues
No response
Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: