Skip to content

[v3-4-test] Pass runtime values to example Dag shell commands through env (#73787) - #75121

Merged
potiuk merged 1 commit into
v3-4-testfrom
backport-486f836-v3-4-test
Oct 19, 2026
Merged

potiuk merged 1 commit into
v3-4-testfrom
backport-486f836-v3-4-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor
  • Pass runtime values to example Dag shell commands through env

Several example Dags built their shell command text out of values that
are only known at run time: another task's output, or a Dag param
rendered through Jinja. Users copy example Dags into real deployments,
so the pattern they show is the pattern that ships. Keep the command
text constant and hand the value to the command through env
instead, so the shell never parses it as part of the command.

Add a check-example-dag-shell-commands prek hook that flags a
bash_command (or a @task.bash return value) built with an
f-string, str.format, % or + from a runtime value, or with a
Jinja expression rendering xcom_pull, params or dag_run.conf
into the command text.

Generated-by: Claude Opus 5

  • Pass file_count to the bash decorator example as a string

The decorator example hands the describe_dag_folder XComs straight to env,
and a value that json.loads turned into an int makes the subprocess fail
before the command runs. The BashOperator example is unaffected because its
Jinja templates always render to strings.

Generated-by: Claude Opus 5

  • Align the example Dag shell-command hook with the other prek scripts

Python 3.10 support is gone and the other prek scripts pin 3.11, so the 3.10 pin made prek provision an extra interpreter just for this hook. The prose also follows the project's "Dag" spelling.
(cherry picked from commit 486f836)

Co-authored-by: Jarek Potiuk jarek@potiuk.com
Generated-by: Claude Opus 5

… env (#73787)

* Pass runtime values to example Dag shell commands through env

Several example Dags built their shell command text out of values that
are only known at run time: another task's output, or a Dag param
rendered through Jinja. Users copy example Dags into real deployments,
so the pattern they show is the pattern that ships. Keep the command
text constant and hand the value to the command through ``env``
instead, so the shell never parses it as part of the command.

Add a ``check-example-dag-shell-commands`` prek hook that flags a
``bash_command`` (or a ``@task.bash`` return value) built with an
f-string, ``str.format``, ``%`` or ``+`` from a runtime value, or with a
Jinja expression rendering ``xcom_pull``, ``params`` or ``dag_run.conf``
into the command text.

Generated-by: Claude Opus 5

* Pass file_count to the bash decorator example as a string

The decorator example hands the describe_dag_folder XComs straight to env,
and a value that json.loads turned into an int makes the subprocess fail
before the command runs. The BashOperator example is unaffected because its
Jinja templates always render to strings.

Generated-by: Claude Opus 5

* Align the example Dag shell-command hook with the other prek scripts

Python 3.10 support is gone and the other prek scripts pin 3.11, so the 3.10 pin made prek provision an extra interpreter just for this hook. The prose also follows the project's "Dag" spelling.
(cherry picked from commit 486f836)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the backport-486f836-v3-4-test branch from d91836c to 4657821 Compare October 19, 2026 20:39
@potiuk
potiuk merged commit a1d5158 into v3-4-test Oct 19, 2026
5 checks passed
@potiuk
potiuk deleted the backport-486f836-v3-4-test branch October 19, 2026 20:42
vatsrahul1001 pushed a commit that referenced this pull request Oct 20, 2026
… env (#73787) (#75121)

* Pass runtime values to example Dag shell commands through env

Several example Dags built their shell command text out of values that
are only known at run time: another task's output, or a Dag param
rendered through Jinja. Users copy example Dags into real deployments,
so the pattern they show is the pattern that ships. Keep the command
text constant and hand the value to the command through ``env``
instead, so the shell never parses it as part of the command.

Add a ``check-example-dag-shell-commands`` prek hook that flags a
``bash_command`` (or a ``@task.bash`` return value) built with an
f-string, ``str.format``, ``%`` or ``+`` from a runtime value, or with a
Jinja expression rendering ``xcom_pull``, ``params`` or ``dag_run.conf``
into the command text.

Generated-by: Claude Opus 5

* Pass file_count to the bash decorator example as a string

The decorator example hands the describe_dag_folder XComs straight to env,
and a value that json.loads turned into an int makes the subprocess fail
before the command runs. The BashOperator example is unaffected because its
Jinja templates always render to strings.

Generated-by: Claude Opus 5

* Align the example Dag shell-command hook with the other prek scripts

Python 3.10 support is gone and the other prek scripts pin 3.11, so the 3.10 pin made prek provision an extra interpreter just for this hook. The prose also follows the project's "Dag" spelling.
(cherry picked from commit 486f836)


Generated-by: Claude Opus 5

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant