Repository navigation
Fix misleading type errors from expand_kwargs and default_args - #73120
Eason09053360 wants to merge 1 commit into
Conversation
Someone who puts a bad element in an expand_kwargs list was told the
container's type ("not list"), which contradicts the expected type in the
same sentence and says nothing about the element that was actually
rejected. Someone who passes a bad default_args was told the type of
task_params instead -- often ParamsDict, an internal wrapper they never
supplied, or NoneType when they passed no params at all.
Both messages send a person debugging towards a value that is not the
problem. Reporting the rejected value alongside the container keeps
everything the old message carried, so no input is described with less
detail than before.
|
Hello @Eason09053360 - thank you for your contributions to Apache Airflow! The Airflow community has introduced a limit of 5 open pull requests at a time for contributors without write access to the repository. You currently have 33 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:
These pull requests stay open because maintainers are already engaged in them - they count towards your limit:
This is not a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are. What we ask you to do is to make your first prioritization decision: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack. Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst. Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting |
Why
Two
TypeErrormessages in the Task SDK name a value that is not the one being rejected, so they point a person debugging at the wrong thing.expand_kwargsvalidates a list element-by-element, but reports the container's type:The list is exactly what
expand_kwargswants — the5inside it is the problem, and the message never mentions it.git log -Straces this to #25925, which added the element loop by copying the existingraiseand updating the message text but not thetype(kwargs)in it. Theelifbranch below it, wherekwargsreally is the rejected value, was left correct.get_merged_defaultsreportstask_paramswhen it rejectstask_default_args:Neither message names
list, which is what the caller actually passed asdefault_args.What
task-sdk/src/airflow/sdk/bases/operator.py—get_merged_defaultsreportstask_default_args.task-sdk/src/airflow/sdk/bases/decorator.py,definitions/mappedoperator.py,definitions/decorators/task_group.py— the element loop in all threeexpand_kwargsimplementations now reports the container and the element:not list containing int.Reporting both matters because
strandbytesareSequences and take the element loop too. Naming only the element would describeexpand_kwargs("abc")asnot list[str]andexpand_kwargs(b"ab")asnot list[int], both worse than today'snot str/not bytes;bytearrayandmemoryviewbehave the same way, so there is no short list of types to special-case. Keeping the container type means no input is described with less detail than before, and atupleof dicts with one bad element now readsnot tuple containing intinstead of the misleadingnot tuple.These four error paths had no test coverage, which is how the
expand_kwargsslip survived since 2022. Each site gets a parametrized test covering the rejected element, the rejected container (guarding theelifbranch that was already correct), andstr/bytes.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines