bujjibabukatta opened a new pull request, #70439:
URL: https://github.com/apache/airflow/pull/70439
Part of the template-field validation/transformation burn-down tracked in
#70296.
`BashOperator.__init__` computed `self._is_inline_cmd` by inspecting the raw,
un-rendered `bash_command` template field. Since template fields are only
resolved to their real value *after* the constructor runs, a DAG author
templating a script path (e.g. `bash_command="{{ params.script_path }}"`)
would get silently misclassified as an inline command instead of a script
file, because the raw Jinja string doesn't end in `.sh`/`.bash` — only the
rendered value would.
This PR moves that classification into `execute()`, after Airflow has
rendered `bash_command`, matching the pattern already used by the
`@task.bash` decorator (`_BashDecoratedOperator.execute`).
**Changes:**
- `providers/standard/src/airflow/providers/standard/operators/bash.py`:
`__init__` now only declares `self._is_inline_cmd = None`; the actual
inline-vs-script-file check happens in `execute()` against the rendered
`self.bash_command`.
- `providers/standard/tests/unit/standard/operators/test_bash.py`: added
regression tests asserting `_is_inline_cmd` is `None` right after
construction and correctly derived only at `execute()` time.
- `scripts/ci/prek/validate_operators_init_exemptions.txt`: removed the now-
fixed `BashOperator` entry, as required by the `validate-operators-init`
hook.
**Testing:** Ran the `validate_operators_init.py` prek hook directly against
the modified file — no violations reported (previously flagged). Added unit
tests cover both the "not yet classified at init" and "classified after
execute()" behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]