amoghrajesh commented on issue #50666:
URL: https://github.com/apache/airflow/issues/50666#issuecomment-2897383636

   Did some investigation on this one. This issue is not applicable only to AWS 
secrets manager but is a general issue with any secrets backend, because of a 
bug in Variable.get().
   
   Set up a `airflow.secrets.local_filesystem.LocalFilesystemBackend` and 
checked with both Airflow 2 and Airflow 3.
   
   var.json
   ```
   {
       "A": "{\"num1\": 23, \"num2\": 42}"
   }
   ```
   
   Dag used:
   ```
   from __future__ import annotations
   
   from airflow.models import Variable
   from airflow.models.baseoperator import BaseOperator
   from airflow import DAG
   # from airflow.sdk import Variable
   
   class CustomOperator(BaseOperator):
       def execute(self, context):
           v = Variable.get(key="A")
           print("Got value", v, type(v))
   
   
           v1 = Variable.get(key="A", deserialize_json=True)
           print("Got value from deser", v1, type(v1))
   
   
   with DAG("get-var-sdk", schedule=None, catchup=False) as dag:
       CustomOperator(task_id="set_var")
   ```
   
   Airflow 2:
   ```
   # With secrets backned
   # [2025-05-20, 16:38:47 IST] {logging_mixin.py:190} INFO - Got value 
{"num1": 23, "num2": 42} <class 'str'>
   # [2025-05-20, 16:38:47 IST] {logging_mixin.py:190} INFO - Got value from 
deser {'num1': 23, 'num2': 42} <class 'dict'>
   ```
   
   Airflow 3:
   ```
   [2025-05-21, 15:35:41] INFO - Got value {"num1": 23, "num2": 42} <class 
'str'>: chan="stdout": source="task"
   [2025-05-21, 15:35:41] INFO - Got value from deser {"num1": 23, "num2": 42} 
<class 'str'>: chan="stdout": source="task"
   ```
   
   As observed the second print for Airflow 3 is a string when it should really 
be a dictionary.
   
   


-- 
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