Fix custom function input not binding positionally when column name d… - #1166
Open
mborodii-prog wants to merge 3 commits into
Open
Fix custom function input not binding positionally when column name d…#1166mborodii-prog wants to merge 3 commits into
mborodii-prog wants to merge 3 commits into
Conversation
…oesn't match a parameter (#747) Row-wise custom functions only bound values to parameters by exact column-name/parameter-name equality. When `input:` mapped a column to a function whose parameter names didn't match (e.g. func(x, y="default", z="default") fed by a column named something else), the value was silently dropped and the function was called without it, surfacing as a missing-argument TypeError instead of resolving the trailing defaults. Falls back to binding unmatched input column(s) positionally to the function's remaining unfilled parameters, in declared order, only when no name-based match exists at all - preserving existing name-matching and literal input/output-as-parameter behavior.
Apply the same positional-binding fallback introduced for #747 even when `input:` isn't specified at all - as long as none of the dataframe's columns match the function's parameter names, and their count fits within the function's remaining unfilled parameters, they now bind positionally in declared order instead of only working when `input:` explicitly names the mismatched column(s). Also relax an unrelated flaky assertion in test_ai_invalid_model_per_row_error: OpenAI now reports an unknown model as a 404 model_not_found rather than the 400 this test assumed, so check for any 4xx client error instead of pinning to one code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sPSwydeh9Juqhr5nRvL9i
mborodii-prog
marked this pull request as ready for review
September 4, 2026 13:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #747 — custom row-wise functions silently dropped a column's value whenever it didn't exactly match one of the function's parameter names, producing a confusing
TypeErrorinstead of resolving the function's other parameters against their defaults.**kwargs). If a column's name didn't match a parameter name, its value was discarded entirely and the function was called without it.input:or from the dataframe as a whole wheninput:isn't given at all.ValueErrornaming exactly what's expected vs. what was given.Examples
1. Mismatched column name via
input:my_col→ paramx,y/zdefaultTypeError: func() missing 1 required positional argument: 'x'result = "row1-default-default"2. Mismatched column, no
input:at allDataframe has one column
my_col(no name match) → same result as above,result = "row1-default-default". Previously this also failed the same way.3. Multiple mismatched columns bind positionally, in order
resultcol_acol_a → x;y/zdefault"col_a_v1-default-default"col_a,col_bcol_a → x,col_b → y;zdefault"col_a_v1-col_b_v1-default"col_a,col_b,col_ccol_a → x,col_b → y,col_c → z"col_a_v1-col_b_v1-col_c_v1"4. Too many unmatched columns → clear error
Dataframe has 4 columns (
a,b,c,d) for a 3-parameter function:TypeError: func() missing 1 required positional argument: 'x'(misleading — implies something's missing, not that too much was given)ValueError: custom.func accepts at most 3 unfilled parameter(s) (x, y, z) but 4 column(s) were provided: a, b, c, dThe fallback only ever engages when there's zero name-based match, so existing name-matching and literal
input/output-as-parameter behavior is unchanged.Changes
wrangles/recipe.py: positional-binding fallback and too-many-columns guard in the row-wise custom-function dispatch (_execute_wrangles).tests/recipes/test_custom_functions.py: regression tests for each of the four scenarios above.tests/recipes/wrangles/test_extract.py: unrelated flaky-test fix —test_ai_invalid_model_per_row_errorwas pinned tostatus=400for an unknown model, but OpenAI now reports that as404 model_not_found; relaxed to accept any 4xx client error.