You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "m1racoli (via GitHub)" <gi...@apache.org> on 2026/04/16 01:24:05 UTC

[I] Object of type `DagRunProtocol` has no attribute `partition_key` [airflow]

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

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.2.0
   
   ### What happened and how to reproduce it?
   
   When type checking the following code:
   
   ```python
   from airflow.sdk import CronPartitionTimetable, dag, get_current_context, task
   
   
   @task
   def example():
       ctx = get_current_context()
       print(type(ctx["dag_run"]))
       print(ctx["dag_run"].partition_key)
   
   
   @dag(
       schedule=CronPartitionTimetable("0 23 * * *", timezone="UTC"),
   )
   def asset_partitioning():
   
       example()
   
   
   asset_partitioning()
   ```
   
   we get the following error for `ctx["dag_run"].partition_key`:
   
   ```
   Object of type `DagRunProtocol` has no attribute `partition_key`
   ```
   
   but when running the task everything works fine:
   
   ```
   [2026-04-15 19:21:43] INFO - DAG bundles loaded: dags-folder
   [2026-04-15 19:21:43] INFO - Filling up the DagBag from /usr/local/airflow/dags/asset_partitioning.py
   [2026-04-15 19:21:43] INFO - TaskInstance Details:  dag_id=asset_partitioning task_id=example dagrun_id=scheduled__2026-04-15T23:00:00+00:00__2026-04-15T23:00:00__BC4C5IYH map_index=-1 run_start_date=2026-04-16T01:21:43.052300Z try_number=2 op_classpath=["airflow.providers.standard.decorators.python._PythonDecoratedOperator","airflow.sdk.bases.decorator.DecoratedOperator","airflow.providers.standard.operators.python.PythonOperator","airflow.sdk.bases.operator.BaseAsyncOperator"]
   [2026-04-15 19:21:43] INFO - Done. Returned value was: None
   [2026-04-15 19:21:43] INFO - <class 'airflow.sdk.api.datamodels._generated.DagRun'>
   [2026-04-15 19:21:43] INFO - 2026-04-15T23:00:0
   ```
   
   The question wether Context.dag_run has correctly typed with DagRunProtocol instead of `airflow.sdk.api.datamodels._generated.DagRun` or if DagRunProtocol is missing `partition_key` in its definition.
   
   ### What you think should happen instead?
   
   _No response_
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _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: commits-unsubscribe@airflow.apache.org.apache.org

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


Re: [I] Object of type `DagRunProtocol` has no attribute `partition_key` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed issue #65339: Object of type `DagRunProtocol` has no attribute `partition_key`
URL: https://github.com/apache/airflow/issues/65339


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