Repository navigation
Fix NoneType crash in FunctionMetadata.fields() for unnamed function args - #1659
Open
ParamTanna wants to merge 1 commit into
Open
ParamTanna wants to merge 1 commit into
ParamTanna wants to merge 1 commit into
Conversation
…li#1204) fields() guarded only arg_modes, but a function argument can arrive with no name (an unnamed variadic arg), so arg_names is None while arg_modes is set, and the zip() raised NoneType is not iterable during completion. args() right above already guards arg_names; fields() now guards it too, falling back to the function-name output column as the no-output-parameters branch does.
This branch has not been deployed
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.
Closes #1204.
FunctionMetadata.fields()crashes withTypeError: 'NoneType' object is not iterablewhile building column completions for certain functions. The reporter hit it on a variadic function, and a PostgreSQL argument can arrive with no name, soarg_names(and/orarg_types) isNonewhilearg_modesis set. Thezip(self.arg_names, self.arg_types, self.arg_modes)at the bottom offields()then fails.args(), right abovefields(), already guards this withif not self.arg_names: return [].fields()only guardedarg_modes, so it missed the case. This extends the existing early-return condition to also coverarg_names/arg_typesbeing falsy, falling back to the function-name output column, which is what the no-output-parameters branch already does.Reproducer without a database:
Added a regression test in
tests/parseutils/test_function_metadata.py, and the existing parseutils tests still pass. Happy to add a changelog entry if you would like one.