Repository navigation
[v3-4-test] Pass runtime values to example Dag shell commands through env (#73787) - #75121
Merged
Merged
Conversation
potiuk
marked this pull request as ready for review
October 19, 2026 19:26
potiuk
requested review from
amoghrajesh,
ashb,
bugraoz93,
dheerajturaga,
gopidesupavan,
jason810496,
jscheffl,
potiuk and
shubhamraj-git
as code owners
October 19, 2026 19:26
… 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
force-pushed
the
backport-486f836-v3-4-test
branch
from
October 19, 2026 20:39
d91836c to
4657821
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
envinstead, so the shell never parses it as part of the command.
Add a
check-example-dag-shell-commandsprek hook that flags abash_command(or a@task.bashreturn value) built with anf-string,
str.format,%or+from a runtime value, or with aJinja expression rendering
xcom_pull,paramsordag_run.confinto the command text.
Generated-by: Claude Opus 5
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
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