Repository navigation
Pass runtime values to example Dag shell commands through env - #73787
Merged
Merged
Conversation
potiuk
requested review from
amoghrajesh,
ashb,
bugraoz93,
dheerajturaga,
gopidesupavan,
jason810496,
jscheffl and
shubhamraj-git
as code owners
September 27, 2026 12:22
potiuk
force-pushed
the
example-dag-env-passing
branch
from
September 27, 2026 15:09
70ba081 to
7c2c245
Compare
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
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
potiuk
force-pushed
the
example-dag-env-passing
branch
from
October 4, 2026 23:27
9a04292 to
466f853
Compare
Member
Author
|
@ephraimbuddy Could you take a look at this when you have a moment? It's targeted at 3.4.0 and needs a review to make the cut on 2026-10-19. CI is green. |
vatsrahul1001
approved these changes
Oct 18, 2026
vatsrahul1001
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. The examples keep the command text constant and pass runtime values through env, and the new hook has tests for the accepted and rejected shapes. Two small comments inline.
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. Generated-by: Claude Opus 5
Contributor
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
potiuk
added a commit
that referenced
this pull request
Oct 19, 2026
… 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
added a commit
that referenced
this pull request
Oct 19, 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>
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>
28 of 93 tasks
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 from 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. These examples now keep the command text constant and pass the value to the command through
env, so the shell never parses it as part of the command.Changed examples:
example_dag_decorator— the IP address fetched byget_ipreachesecho_ip_infothroughEXTERNAL_IP.example_bash_operator/example_bash_decorator—show_dag_folder_statsreadsdescribe_dag_folder's XComs throughenv.integration_test—classic_bashreadsparams.mapping_countthroughenv.A new
check-example-dag-shell-commandsprek hook keeps it that way. On files underexample_dags/it flags abash_command(or a@task.bashreturn value) built with an f-string,str.format,%or+from a runtime value, and a Jinja expression that rendersxcom_pull,paramsordag_run.confinto command text. Literals, module-level constants and context values such as{{ ds }}are fine. The hook has unit tests underscripts/tests/ci/prek/.🤖 Generated with Claude Code