You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "TJaniF (via GitHub)" <gi...@apache.org> on 2025/03/28 16:39:19 UTC

[I] Api-server sqlalchemy.exc.ArgumentError caused by in-task code accessing context for runs without a logical_date [airflow]

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

   ### Apache Airflow version
   
   3.0.0
   
   ### If "Other Airflow 2 version" selected, which one?
   
   breeze current main
   
   ### What happened?
   
   This dag works fine in 2.10 and in 3.0 when the dag has a logical_date supplied on manual run:
   
   ```
   from airflow.decorators import dag, task
   from collections.abc import Mapping
   
   
   def _print_dict(d, indent=0):
       text_output = ""
       for key, value in d.items():
           text_output += " " * indent + f"{key}: "
           if isinstance(value, Mapping):
               text_output += "\n"
               text_output += _print_dict(value, indent + 4)
           else:
               text_output += f"{value}\n"
       return text_output
   
   
   @dag(schedule=None, catchup=False)
   def context_full_test_dag():
       @task
       def print_context(**context):
           print("------ START PRINT CONTEXT ------")
           dict_repr = _print_dict(context)
           print("------ END PRINT CONTEXT ------")
           print(dict_repr)
   
           with open("/files/dags/a", "w") as f:
               f.write(dict_repr)
   
           keys = []
           for key in context.keys():
               keys.append(key)
           print("------ START PRINT KEYS ------")
           print(keys)
           print("------ END PRINT KEYS ------")
   
           import json
           with open(
               "/files/dags/a.json",
               "w",
           ) as f:
               json.dump(keys, f)
   
   
       print_context()
   
   
   context_full_test_dag()
   ```
   
   When the dag is run manually without supplying a logical date, the API server throws a sqlalchemy error (sorry for the screenshot, tmux vscode keybinding mess)
   
   ![Image](https://github.com/user-attachments/assets/5ea39b63-1995-4f8d-bba8-c1ee384cd7db)
   
   The error leads to the scheduler loosing connection to the API server, and eventually the scheduler crashes. (The task gets stuck)
   
   ### What you think should happen instead?
   
   A task error, not an api-server error. 
   Not entirely sure what in the task is causing this.
   
   
   ### How to reproduce
   
   Run the above dag in 3.0 manually without supplying a logical date. 
   
   ### Operating System
   
   MacOS
   
   ### Versions of Apache Airflow Providers
   
   None
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   breeze
   
   ### 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: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Api-server sqlalchemy.exc.ArgumentError caused by in-task code accessing context for runs without a logical_date [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed issue #48503: Api-server sqlalchemy.exc.ArgumentError caused by in-task code accessing context for runs without a logical_date
URL: https://github.com/apache/airflow/issues/48503


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Api-server sqlalchemy.exc.ArgumentError caused by in-task code accessing context for runs without a logical_date [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed issue #48503: Api-server sqlalchemy.exc.ArgumentError caused by in-task code accessing context for runs without a logical_date
URL: https://github.com/apache/airflow/issues/48503


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org