Skip to content

Added meaningful error message for case when task method name is same as inbuilt/ time module method#55252

Closed
suman-himanshu wants to merge 4 commits intoapache:mainfrom
suman-himanshu:improve-error-message-builtin
Closed

Added meaningful error message for case when task method name is same as inbuilt/ time module method#55252
suman-himanshu wants to merge 4 commits intoapache:mainfrom
suman-himanshu:improve-error-message-builtin

Conversation

@suman-himanshu
Copy link
Contributor

Added meaningful error message for case when task method name is same as inbuilt/ time module method

Post running sample DAG provide on github issue -

image

closes #49875


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@suman-himanshu
Copy link
Contributor Author

Hello maintainers,

I have included time and builtins module checks while keeping the author's concern in mind. Please let me know if there are any other modules we should include.

Thank you!

from airflow.sdk.definitions.taskgroup import TaskGroup

STANDARD_NAMES = set(dir(builtins))
STANDARD_NAMES.update(dir(time))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't scalable. Why just the time module? What about the 100s of other modules in the standard library?

Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really see this approach working.

a) There is nothing wrong with calling a task sleep, or any of the other builtin names. This is allowed.
b) The issue is not that the task fn is called sleep, but that the task decorator is trying to be called inside the task function leads to a hard-to-debug error.

That second point is what we want to catch, not that the task name is redecorated

@ashb ashb closed this Sep 24, 2025
@ashb
Copy link
Member

ashb commented Sep 24, 2025

(Sorry to close this PR without discussion, but this approach just won't work, and it would almost certainly break a good portion of DAGs that work today. So this PR is a non-starter.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message for Python decorator invoking function with same name as the task name

2 participants