Skip to content

NoneType exception in get_completions() #1204

Description

@ulidtko

Description

With this SQL:

CREATE EXTENSION hstore;

CREATE OR REPLACE FUNCTION no_labels() RETURNS hstore AS $$
  SELECT hstore(ARRAY[]::text[])
$$ language sql immutable;

CREATE OR REPLACE FUNCTION labels() RETURNS hstore AS $$
  SELECT no_labels()
$$ language sql immutable;

CREATE OR REPLACE FUNCTION labels(variadic text[]) RETURNS hstore AS $$
  SELECT hstore($1)
$$ language sql immutable;

When editing this query:

pgcli> select * from labels()
       --            ^ start inserting each( here

As soon as the ( after each is inserted, this traceback appears:

Unhandled exception in event loop:
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/async_generator.py", line 43, in runner
    for item in get_iterable():
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/completion/base.py", line 226, in <lambda>
    lambda: self.completer.get_completions(document, complete_event)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/completion/base.py", line 262, in get_completions
    return completer.get_completions(document, complete_event)
  File "/home/ulidtko/.local/lib/python3.8/site-packages/pgcli/pgcompleter.py", line 485, in get_completions
    matches.extend(matcher(self, suggestion, word_before_cursor))
  File "/home/ulidtko/.local/lib/python3.8/site-packages/pgcli/pgcompleter.py", line 506, in get_column_matches
    scoped_cols = self.populate_scoped_cols(tables, suggestion.local_tables)
  File "/home/ulidtko/.local/lib/python3.8/site-packages/pgcli/pgcompleter.py", line 985, in populate_scoped_cols
    cols = func.fields()
  File "/home/ulidtko/.local/lib/python3.8/site-packages/pgcli/packages/parseutils/meta.py", line 168, in fields
    for name, typ, mode in zip(self.arg_names, self.arg_types, self.arg_modes)

Exception 'NoneType' object is not iterable
Press ENTER to continue...

Your environment

  • Please provide your OS and version information.
    • Arch Linux
    • PostgreSQL 11 from DockerHub, docker pull postgres:11
  • Please provide your CLI version.
    • 3.0.0
  • What is the output of pip freeze command.
    • is pretty long; I can provide specific dependency versions on request.

Activity

  1. dbaty commented on Sep 27, 2023

    @dbaty
    Member

    This issue is still there in pgcli 3.5.0.

  2. ulidtko commented on Sep 27, 2023

    @ulidtko
    Author

    Ping @amjith ☝️

  3. dbaty commented on Sep 27, 2023

    @dbaty
    Member

    Note: I was triaging old issues and see whether they were still relevant. This one still is. I was not requesting a maintainer to look at it. I know that the issue is unlikely to move on unless someone steps up to contribute a fix. ;) (And since I am not impacted by this issue, I am very unlikely to tackle it.)

  4. ulidtko commented on Sep 27, 2023

    @ulidtko
    Author

    Ah, I see @dbaty 😄 Actually, completely forgot I reported this — glad to see it was quality enough to still stand!

    I ended up not habituating to pgcli... so, not using it. Won't fix this either ofcourse 😅

    Thanks for checking though.

  5. ulidtko commented on Dec 27, 2024

    @ulidtko
    Author

    Hey @j-bennet, how is this "completed", sorry?..

    I'd just retested on pgcli version 4.1.0 (latest released, at the moment) pip-installed on Ubuntu — and it crashes in exactly the same way as reported originally.

    Took 2 minutes to reproduce.

    Here's a screencast, in case you couldn't follow textual description 👀

    pgcli asciicast


    Kindly reopen! This bug isn't fixed.

    cc @dbaty @deronnax

  6. dbaty commented on Dec 30, 2024

    @dbaty
    Member

    This was likely a misclick, I am reopening this issue.

  7. reopened this on Dec 30, 2024
  8. added a commit that references this issue on Oct 19, 2026
    bb5aff9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions