Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken macro support in DataProcJobBuilder task_id parameter #28810

Closed
2 tasks done
rafalh opened this issue Jan 9, 2023 · 4 comments
Closed
2 tasks done

Broken macro support in DataProcJobBuilder task_id parameter #28810

rafalh opened this issue Jan 9, 2023 · 4 comments

Comments

@rafalh
Copy link
Contributor

rafalh commented Jan 9, 2023

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

8.5.0

Apache Airflow version

2.3.4

Operating System

Linux

Deployment

Composer

Deployment details

No response

What happened

I am passing string containing macros to DataProcJobBuilder task_id parameter:

{{ (dag.dag_id + '-' + task.task_id.replace('_', '-'))[:90] }}

I use created job with DataprocSubmitJobOperator.
It worked fine in composer-2.0.27-airflow-2.2.5 (apache-airflow-providers-google==2022.9.6+composer). Now I tried upgrading to composer-2.1.2-airflow-2.3.4 (apache-airflow-providers-google==8.5.0) and it no longer works because after #23791 all "." are replaced by "_" before macro evaluation. It causes error:

'dag_dag_id' is undefined

What you think should happen instead

Optimally DataProcJobBuilder should allow using macros as before.
PR that broke this usage was supposed to fix task groups (#23439). Perhaps that fix (string replacement) could be moved to a different place e.g. DataprocJobBaseOperator default value. This way API of DataProcJobBuilder would still allow macros.

How to reproduce

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@rafalh rafalh added area:providers kind:bug This is a clearly a bug labels Jan 9, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 9, 2023

Thanks for opening your first issue here! Be sure to follow the issue template!

@potiuk
Copy link
Member

potiuk commented Jan 9, 2023

The replacement should be done AFTER running JINJA. Anyone wants to provide a fix? (@eladkal :) ? )

rafalh pushed a commit to rafalh/airflow that referenced this issue Jan 16, 2023
Do not sanitize job name in DataProcJobBuilder because it can use Jinja macros. Move sanitization to DataprocJobBaseOperator default value for job_name parameter to keep supporting task groups.

Fixes apache#28810
Copy link

This issue has been automatically marked as stale because it has been open for 365 days without any activity. There has been several Airflow releases since last activity on this issue. Kindly asking to recheck the report against latest Airflow version and let us know if the issue is reproducible. The issue will be closed in next 30 days if no further activity occurs from the issue author.

Copy link

This issue has been closed because it has not received response from the issue author.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants