Conversation
Fixes dbcli#1204. fields() guarded against a missing arg_modes, but zipped arg_names/arg_types/arg_modes unconditionally otherwise. A function with a truthy arg_modes but no arg_names (e.g. an unnamed variadic parameter, as in the reported hstore/variadic example) hit 'NoneType' object is not iterable instead of being handled. Fall back to None placeholders for arg_names/arg_types the same way args() already falls back for arg_modes a few lines up.
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.
Fixes #1204.
Bug
Autocompleting a call to a table-returning or variadic function whose parameters have no names (e.g. an unnamed
variadic text[]argument, as in the reportedhstore/labels(variadic text[])example) crashes the completion thread:fields()only guards against a missingarg_modes(elif not self.arg_modes: ...), then zipsarg_names/arg_types/arg_modesunconditionally.arg_modesbeing truthy doesn't guaranteearg_namesis populated too — a function can have modes but no names, in which casearg_namesstaysNoneand thezip()raises before it ever gets to filter by mode.Fix
Fall back to
Noneplaceholders forarg_names/arg_typesthe same wayargs()(a few lines up in the same class) already falls back forarg_modes, so the zip always gets iterables.Test plan
test_function_metadata_fields_with_variadic_and_no_arg_names, directly reproducing the reported case viaFunctionMetadata.test_function_metadata_fields_table_mode_with_no_arg_names, checking a TABLE-mode function with unnamed columns returns sensibleColumnMetadata(not just an empty list).TypeErroragainst the unpatched code.pytest tests/ --ignore=tests/features— 2575 passed, 1 pre-existing failure unrelated to this change (a Windows-only tempfile permission issue in an unrelated alias-map test), 1 xfailed, 1 xpassed.ruff check/ruff formatclean.