Repository navigation
Bug: Unable to use expand on a TaskGroup containing a @task.kubernetes_cmd task #56459
Description
Apache Airflow version
3.0.6
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Summary
Since Airflow 3.0 (tested on 3.0.6), it is impossible to use expand on a @task_group containing a task decorated with @task.kubernetes_cmd.
Expansion works correctly for a standalone @task.kubernetes_cmd task, or for a @task_group containing a @task.kubernetes task, but fails in the specific case of a task group + kubernetes_cmd.
The mapped data is not correctly interpreted or propagated.
This code raises an error or does not correctly map the values to the internal TaskGroup task (echo_cmd).
Note: If you replace @task.kubernetes_cmd with @task.kubernetes, it works as expected.
Expected behavior
- Expansion (
expand) on a TaskGroup containing a@task.kubernetes_cmdtask should work just like with other TaskFlow-compatible tasks.
Observed behavior
- The mapping/expand does not pass the expected values to the internal task within the TaskGroup.
- The value injected into the internal task is a
MappedArgumentobject (e.g.,<airflow.models.xcom_arg.MappedArgument object at ...>) instead of the actual value (e.g."foo","bar"). - There is no similar issue with
@task.kubernetesin the same scenario.
Technical details
- When mapping via
expandon a@task_groupcontaining a@task.kubernetes_cmdtask, the value received by the internal task is an unresolvedMappedArgumentobject.
Environment
- Airflow: 3.0.6
- Deployment: via the official Helm chart (apache/airflow)
- Image used:
apache/airflow:3.0.6 - Python version: not explicitly set, using the official image default
Notes / leads
- It seems that expand/mapping on TaskGroups does not work with this specific decorator, while it does with others.
- No existing issue found as of October 2025.
Thanks for your help and for all your great work on Airflow!
What you think should happen instead?
No response
How to reproduce
from airflow.decorators import dag, task, task_group
from datetime import datetime
@dag(start_date=datetime(2023,1,1), schedule=None, catchup=False)
def demo():
@task
def make_values():
return ["foo", "bar", "baz"]
@task.kubernetes_cmd(image="alpine")
def echo_cmd(name):
return ["echo", name]
@task_group
def group_task(name):
echo_cmd(name)
# This works:
# echo_cmd.expand(name=make_values())
# This does NOT work:
group_task.expand(name=make_values())
dag = demo()Operating System
apache/airflow:3.0.6
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow 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
- I agree to follow this project's Code of Conduct
Activity
boring-cyborg commentedon Oct 7, 2025
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
Mazen94 commentedon Oct 8, 2025
+1 I’m experiencing the same issue on Airflow
Nonolabiscotte commentedon Oct 8, 2025
+1, I can confirm this is happening on Airflow.
ashb commentedon Oct 21, 2025
Can someone please include the full error?
SoinSoin commentedon Oct 24, 2025
tmaurin commentedon Oct 30, 2025
Hello @ashb,
I don't know where you are with this issue, but in case it can help you, I think this issue might actually be linked to taskGroup + template variable referencing another template variable rather than taskgroup + kubernetes_cmd directly.
I think this dag is showcasing the issue:
This is the resulting graph:
The mapped task though the test_group have a log along this line:
While the task mapped directly have a log along this line:
So mapping directly the task work as expected/like in 2.X while mapping through a taskgroup does not.
ashb commentedon Oct 30, 2025
I haven't made any start on this issue, I've only some some preliminary triage.
tmaurin commentedon Oct 30, 2025
Small update:
I'm not 100% it is the same thing, but I found out you can reproduce the issue by using an fstring instead of referencing another variable.
In case it can be usefull starting from above example for the TaskGroup:
Will print:
akkik04 commentedon Dec 6, 2025
i want to take a shot at this, can one of the maintainers assign to me please. 🙌
akkik04 commentedon Dec 11, 2025
Put up a PR for this, looking forward to getting some eyes on it. 🙌
cc: @ephraimbuddy @kaxil