Commit ab48b2b
authored
Fix
The ``example_bash_decorator`` was broken since it relied on the Airflow source code path.
Before:
```
{"timestamp":"2025-09-23T11:44:15.971920Z","level":"info","event":"Running command: ['/usr/bin/bash', '-c', 'stat']","logger":"airflow.task.hooks.airflow.providers.standard.hooks.subprocess.SubprocessHook","filename":"subprocess.py","lineno":88}
{"timestamp":"2025-09-23T11:44:15.995649Z","level":"info","event":"Output:","logger":"airflow.task.hooks.airflow.providers.standard.hooks.subprocess.SubprocessHook","filename":"subprocess.py","lineno":99}
{"timestamp":"2025-09-23T11:44:15.999568Z","level":"info","event":"stat: missing operand","logger":"airflow.task.hooks.airflow.providers.standard.hooks.subprocess.SubprocessHook","filename":"subprocess.py","lineno":106}
{"timestamp":"2025-09-23T11:44:15.999669Z","level":"info","event":"Try 'stat --help' for more information.","logger":"airflow.task.hooks.airflow.providers.standard.hooks.subprocess.SubprocessHook","filename":"subprocess.py","lineno":106}
{"timestamp":"2025-09-23T11:44:16.000278Z","level":"info","event":"Command exited with return code 1","logger":"airflow.task.hooks.airflow.providers.standard.hooks.subprocess.SubprocessHook","filename":"subprocess.py","lineno":110}
{"timestamp":"2025-09-23T11:44:16.000884Z","level":"error","event":"Task failed with exception","logger":"task","filename":"task_runner.py","lineno":972,"error_detail":[{"exc_type":"AirflowException","exc_value":"Bash command failed. The command returned a non-zero exit code 1.","exc_notes":[],"syntax_error":null,"is_cause":false,"frames":[{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py","lineno":920,"name":"run"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py","lineno":1307,"name":"_execute_task"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py","lineno":416,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/standard/decorators/bash.py","lineno":100,"name":"execute"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py","lineno":416,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/decorator.py","lineno":252,"name":"execute"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py","lineno":416,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/standard/operators/bash.py","lineno":232,"name":"execute"}],"is_group":false,"exceptions":[]}]}
{"timestamp":"2025-09-23T11:44:16.025800Z","level":"info","event":"Task instance in failure state","logger":"task.stdout"}
{"timestamp":"2025-09-23T11:44:16.025944Z","level":"info","event":"Task start","logger":"task.stdout"}
{"timestamp":"2025-09-23T11:44:16.026033Z","level":"info","event":"Task:<Task(_BashDecoratedOperator): get_file_stats>","logger":"task.stdout"}
{"timestamp":"2025-09-23T11:44:16.026135Z","level":"info","event":"Failure caused by Bash command failed. The command returned a non-zero exit code 1.","logger":"task.stdout"}
```
After:
```
[2025-09-24 02:12:47] INFO - Task instance is in running state
[2025-09-24 02:12:47] INFO - Previous state of the Task instance: TaskInstanceState.QUEUED
[2025-09-24 02:12:47] INFO - Current task name:get_file_stats
[2025-09-24 02:12:47] INFO - Dag name:example_bash_decorator
[2025-09-24 02:12:47] INFO - Tmp dir root location: /tmp
[2025-09-24 02:12:47] INFO - Running command: ['/usr/bin/bash', '-c', 'stat /opt/airflow/airflow-core/src/airflow/example_dags/standard/example_bash_decorator.py']
[2025-09-24 02:12:47] INFO - Output:
[2025-09-24 02:12:47] INFO - File: /opt/airflow/airflow-core/src/airflow/example_dags/standard/example_bash_decorator.py
[2025-09-24 02:12:47] INFO - Size: 3867 Blocks: 8 IO Block: 4096 regular file
[2025-09-24 02:12:47] INFO - Device: 0,34 Inode: 2057958327228072012 Links: 1
[2025-09-24 02:12:47] INFO - Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
[2025-09-24 02:12:47] INFO - Access: 2025-09-24 01:12:17.366858270 +0000
[2025-09-24 02:12:47] INFO - Modify: 2025-09-24 01:08:56.992964565 +0000
[2025-09-24 02:12:47] INFO - Change: 2025-09-24 01:08:56.992964565 +0000
[2025-09-24 02:12:47] INFO - Birth: -
[2025-09-24 02:12:47] INFO - Command exited with return code 0
[2025-09-24 02:12:47] INFO - Pushing xcom ti=RuntimeTaskInstance(id=UUID('01997947-a73f-77ea-a2d0-a4d63f57bf03'), task_id='get_file_stats', dag_id='example_bash_decorator', run_id='manual__2025-09-24T01:12:42.913441+00:00', try_number=1, dag_version_id=UUID('01997947-6324-771c-ae0e-4a01d869e171'), map_index=-1, hostname='72ace79a9422', context_carrier={}, task=<Task(_BashDecoratedOperator): get_file_stats>, bundle_instance=LocalDagBundle(name=example_dags), max_tries=0, start_date=datetime.datetime(2025, 9, 24, 1, 12, 47, 289149, tzinfo=datetime.timezone.utc), end_date=None, state=<TaskInstanceState.RUNNING: 'running'>, is_mapped=False, rendered_map_index=None)
[2025-09-24 02:12:47] INFO - Task instance in success state
[2025-09-24 02:12:47] INFO - Previous state of the Task instance: TaskInstanceState.RUNNING
[2025-09-24 02:12:47] INFO - Task operator:<Task(_BashDecoratedOperator): get_file_stats>
```example_bash_decorator DAG (apache#56020)1 parent e80a6cc commit ab48b2b
File tree
1 file changed
+4
-11
lines changed- providers/standard/src/airflow/providers/standard/example_dags
1 file changed
+4
-11
lines changedLines changed: 4 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | 95 | | |
104 | 96 | | |
| 97 | + | |
105 | 98 | | |
106 | 99 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
110 | 103 | | |
111 | 104 | | |
112 | 105 | | |
| |||
0 commit comments