Expanded argument nor working on KubernetesPodOperator task inside expanded Task Group

all!

I’m trying to create a task group for each list of params dynamically generated in my DAG. Everything goes fine until I try to use the expanded arguments as an input for a KubernetesPodOperator inside a task group. What am I missing?

Sample code:

`with airflow.DAG(
DAG_ID,
default_args=default_args,
tags=tags_,
schedule_interval=SCHEDULE_INTERVAL,
is_paused_upon_creation=False,
catchup=False,
max_active_tasks=POOL_SIZE,
max_active_runs=1,
) as dag:

@task
def fetch_tables(dbtables, **context):

    user_tables = ['table01', 'table02', ... ]
    context['ti'].xcom_push(key='ok_tables', value=list(set(user_tables).intersection(set(dbtables))))
    context['ti'].xcom_push(key='missing_tables', value=list(set(dbtables).difference(set(user_tables))))


@task
def gen_params(**context):

    ok_tables = context['ti'].xcom_pull(key='ok_tables', task_ids='fetch_tables')

    return [ 
        { 
            'env_vars' : {
                "JOB_DBTABLE": tabela,
                "JOB_TAB_INDEX": f"{tab_index}",
            }
        } for tab_index, tabela in enumerate(ok_tables) ]

@task_group
def ingestao_task_group(job_params):
   
    comando_submit = KubernetesPodOperator(
        task_id="comando_submit",
        retries=10,
        name=f'{POD_NAME_PREFIX}-driver',
        image="mycustomimage:latest",
        in_cluster=True,
        namespace="airflow",
        service_account_name='airflow-worker',
        image_pull_policy="Always",
        random_name_suffix=True,
        pool=POOL_NAME,
        env_vars=job_params,
    )


job_params = gera_params()
fetch_tables(eval(DBTABLES_JSON)) >> job_params
ingestao_task_group.expand(job_params=job_params)

`

I got the error below:

Broken DAG: [/some/path/to/mydag.py]
Traceback (most recent call last):
File “/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/cncf/kubernetes/operators/pod.py”, line 324, in init
env_vars = convert_env_vars(env_vars) if env_vars else []
File “/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/cncf/kubernetes/backcompat/backwards_compat_converters.py”, line 82, in convert_env_vars
raise AirflowException(f”Expected dict or list, got {type(env_vars)}”)
airflow.exceptions.AirflowException: Expected dict or list, got <class ‘airflow.models.expandinput.MappedArgument’>

I tried to extract the mapped argument in a previous task before using inside the KubernetesPodOperator:

    @task_group
    def ingestao_task_group(job_params):
       
        @task
        def extract_job_params(job_params):

            print('#'*20, 'job_params', job_params.get('env_vars'))

            return job_params.get('env_vars')
        
        # extracted_job_params = extract_job_params(job_params=job_params)

        comando_submit = KubernetesPodOperator(
            [...]
            env_vars=extract_job_params(job_params=job_params),
        )

But then I got this instead:

Broken DAG: [.../ dag-teste.py]
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/cncf/kubernetes/operators/pod.py", line 324, in __init__
    env_vars = convert_env_vars(env_vars) if env_vars else []
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/cncf/kubernetes/backcompat/backwards_compat_converters.py", line 82, in convert_env_vars
    raise AirflowException(f"Expected dict or list, got {type(env_vars)}")
airflow.exceptions.AirflowException: Expected dict or list, got <class 'airflow.models.xcom_arg.PlainXComArg'>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật