tyama711 opened a new issue, #39577:
URL: https://github.com/apache/airflow/issues/39577

   ### 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:
   
   - When the specified key does not exist in environment variables or Metastore
   - When there is a connection failure to Metastore or some other error
   
   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:
   
https://github.com/apache/airflow/blob/defe4590e9c94a9b5157143d618a143cb30ade78/airflow/models/variable.py#L286-L291
   
   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:
   
   - When the specified key does not exist in environment variables or 
Metastore --> Use some default value
   - When there is a connection failure to Metastore or some other error --> 
Retry several times, and if unsuccessful, fail the job.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to