nailo2c opened a new pull request, #57782:
URL: https://github.com/apache/airflow/pull/57782

   Closes: #50327 
   
   # Why
   
   
https://github.com/apache/airflow/blob/734960df055b09cfa52a905664acfd576a504cc9/task-sdk/src/airflow/sdk/definitions/_internal/decorators.py#L76-L85
   
   The function `remove_task_decorator` uses `cst.parse_module` to parse the 
python source.
   
   However, when the function source contains unusual indentation (e.g., a 
comment at column-0 inside an indented function), `cst.parse_module` fails and 
raises a `cst.ParserSyntaxError`.
   
   ```python
       def b_task():
           print("hello")
   ##################
           print("more hello")
   ```
   
   Because this exception was not caught, the function fails early. This 
prevents the `@task.kubernetes` decorator from being removed, causing it to be 
incorrectly included in the generated `/tmp/script.py`.
   
   This leads to the final error reported in the issue: `NameError: name 'task' 
is not defined` when the pod tries to execute the script.
   
   # How
   
   Add a regex fallback for `@task.kubernetes` and handle the indentation issue.
   
   # What
   
   <img width="1505" height="964" alt="image" 
src="https://github.com/user-attachments/assets/c7281ef2-bdc3-4cb4-a769-858021c46d7e";
 />
   


-- 
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]

Reply via email to