Skip to content

Clarify task decorator argument errors (#49875) - #69157

Open
deepujain wants to merge 2 commits into
apache:mainfrom
deepujain:fix-49875-task-decorator-error-hint
Open

Clarify task decorator argument errors (#49875)#69157
deepujain wants to merge 2 commits into
apache:mainfrom
deepujain:fix-49875-task-decorator-error-hint

Conversation

@deepujain

@deepujain deepujain commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Title: Clarify task decorator argument errors (#49875)

Summary

Calling a decorated task object like a regular function can raise a bare TypeError: too many positional arguments, which makes the reported name-shadowing failure hard to diagnose. This keeps the existing binding validation but adds a targeted hint only when the binding failure already happened for extra positional arguments.

Changes

  • task-sdk/src/airflow/sdk/bases/decorator.py -- wrap signature binding errors and append an accidental decorated-task-call hint only for extra positional arguments.
  • task-sdk/tests/task_sdk/bases/test_decorator.py -- add regression coverage for the accidental call case and verify missing required arguments do not receive the hint.
  • airflow-core/newsfragments/69157.bugfix.rst -- add a bugfix release note for the user-facing error-message improvement.

Evidence it works

  • The regression test recreates the reported decorated-task self-call shape and asserts that the error includes the new accidental-call hint.
  • A separate negative test keeps missing-required-argument binding errors unchanged, so the hint is limited to the extra-positional-argument case.
  • The implementation works on the existing bind-validation path and does not inspect the call stack on the happy path.

Test plan

  • uvx --from uv==0.11.21 uv run --project task-sdk ruff format --check task-sdk/src/airflow/sdk/bases/decorator.py task-sdk/tests/task_sdk/bases/test_decorator.py
  • uvx --from uv==0.11.21 uv run --project task-sdk ruff check task-sdk/src/airflow/sdk/bases/decorator.py task-sdk/tests/task_sdk/bases/test_decorator.py
  • uvx --from uv==0.11.21 uv run --project task-sdk pytest task-sdk/tests/task_sdk/bases/test_decorator.py::TestDefaultFillingLogic::test_bind_validation_hints_for_accidental_task_decorator_call task-sdk/tests/task_sdk/bases/test_decorator.py::TestDefaultFillingLogic::test_bind_validation_missing_required_args_has_no_accidental_call_hint -xvs
  • CI passes
Was generative AI tooling used to co-author this PR?
  • Yes (OpenAI Codex)

Generated-by: OpenAI Codex following the guidelines

Fixes #49875

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@deepujain please note that you (or your operator) should include AI attribution in the PR as we state in the AI guidelines.
This PR, as well as others, are blocked from being merged until this is corrected.
Please be warned that creating additional PRs except for the 10 you've already created (listed below) without addressing the above might cause in a permanent block from Apache organization on GitHub.

List of PRs:

@shahar1
shahar1 dismissed their stale review June 30, 2026 06:27

AI attribution addressed

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 2, 2026
@deepujain
deepujain force-pushed the fix-49875-task-decorator-error-hint branch from 2c14d36 to 8ac47bd Compare August 5, 2026 12:00
@deepujain

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main. Ruff formatting and lint both pass, and the two targeted Task SDK regression tests pass (2 passed). No source changes were needed beyond the rebase.


Drafted-by: OpenAI Codex (no human review before posting)

@deepujain
deepujain force-pushed the fix-49875-task-decorator-error-hint branch from 8ac47bd to 5fdd4b4 Compare August 6, 2026 08:57
@deepujain

Copy link
Copy Markdown
Contributor Author

The three provider compatibility jobs failed while importing an incompatible pyOpenSSL during unrelated provider test collection (GEN_EMAIL). I rebased onto current main, which includes #71145's resolver fix. Ruff passes, and the two targeted Task SDK tests pass locally.


Drafted-by: OpenAI Codex (no human review before posting)

@deepujain
deepujain force-pushed the fix-49875-task-decorator-error-hint branch from 5fdd4b4 to c9485a7 Compare August 7, 2026 12:44
@deepujain

Copy link
Copy Markdown
Contributor Author

Rebased onto current main at e24f5294. Ruff formatting and lint pass, and the two targeted Task SDK regression tests pass (2 passed); no source changes were needed.


Drafted-by: OpenAI Codex (no human review before posting)

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

Labels

area:task-sdk ready for maintainer review Set after triaging when all criteria pass.

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

3 participants