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

   ### Body
   
   Given this dag:
   
   ```python
   import time
   import sys
   from airflow.decorators import dag, task
   from airflow.sdk import Variable
   
   from airflow.utils.session import create_session
   
   if Variable.get("hi"):
       raise RuntimeError("No var hi")
       ...
   
   
   @dag(schedule=None)
   def hello_airflow_dev_call():
       @task()
       def hello():
           print("hello")
           time.sleep(3)
           print("goodbye")
           print("err mesg", file=sys.stderr)
   
       hello()
   
       try:
           with create_session():
               pass
   
           @task
           def db_access():
               pass
   
           db_access()
       except Exception:
   
           @task
           def without_db_access():
               with create_session():
                   pass
   
           without_db_access()
   
   
   hello_airflow_dev_call()
   ```
   
   It fails (which is okay, that is expected if the variable "hi" does not 
exist)
   
   What is not okay is the parse error that is recored:
   
   ```
   Traceback (most recent call last):
     File 
"/Users/ash/code/airflow/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py",
 line 455, in get_message
       msg = self.decoder.validate_json(line)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/Users/ash/code/airflow/airflow/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py",
 line 446, in validate_json
       return self.validator.validate_json(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   pydantic_core._pydantic_core.ValidationError: 1 validation error for 
tagged-union[DagFileParseRequest,ConnectionResult,VariableResult]
     Input tag 'ErrorResponse' found using 'type' does not match any of the 
expected tags: 'DagFileParseRequest', 'ConnectionResult', 'VariableResult' 
[type=union_tag_invalid, input_value={'error': 'VARIABLE_NOT_F...'type': 
'ErrorResponse'}, input_type=dict]
       For further information visit 
https://errors.pydantic.dev/2.10/v/union_tag_invalid
   ```
   
   ### Committer
   
   - [x] I acknowledge that I am a maintainer/committer of the Apache Airflow 
project.


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