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

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### What happened
   
   In Airflow 2.3.3, when setting an environment variable such as 
`AIRFLOW_VAR_ENVIRONMENT` to `testing` I am getting a Broken Dag error. The 
error message is 
   
   ```
   Broken DAG: [/blah/file.py] Traceback (most recent call last):
     File "/blah/environment.py", line 62, in _get_environment
       return Variable.get('environment')
     File 
"/usr/local/autotrader/lib/python3.8/site-packages/airflow/models/variable.py", 
line 138, in get
       raise KeyError(f'Variable {key} does not exist')
   KeyError: 'Variable environment does not exist'
   ```
   
   I've checked the database and the variable is not set in there, which may be 
the expected behaviour as it doesn't show in the UI which is expected. When I 
run `airflow variables get environment` it does return the expected value, 
however, in a dag running `Variables.get('environment') it doesn't get the 
variable. 
   
   ### What you think should happen instead
   
   The expected behaviour would be that when running 
Variables.get('environment') in a dag, that it would return the expected value.
   
   ### How to reproduce
   
   Set a variable as an environment variable and try getting the variable in a 
dag using `Variables.get('<ENV_NAME>'). This would result in a Broken Dag error.
   
   ### Operating System
   
   Rocky Linux 8.7
   
   ### Versions of Apache Airflow Providers
   
   Airflow v2.3.3
   
   ### Deployment
   
   Other 3rd-party Helm chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit 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