Skip to content

Running into TypeError: can only concatenate str (not "list") to str #190

@hv15

Description

@hv15

Hi,

Recently, I've run into an issue when using AIChat where the returned request response is malformed (is a list instead of a string):

>>> user

Test


<<< error getting response: can only concatenate str (not "list") to str

```python
Traceback (most recent call last):
  File "/home/hans/.vim/plugged/vim-ai/py/chat.py", line 180, in run
    self.buffer += chunk["content"]
TypeError: can only concatenate str (not "list") to str

```

<<< assistant

>>> user

I'm using the latest commit 8887f9f and am running vim 9.1 on ArchLinux. I suspect something has changed with the Python requests package which is causing the above issue, I have version 2.32.5 installed.

Additionally, I also get an error when running just AIEdit, and suspect it is due to the same issue:

Error detected while processing function vim_ai#AIEditRun[31]..function vim_ai#AIEditRun:                                                                                              
line   28:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/hans/.vim/plugged/vim-ai/py/complete.py", line 41, in run_ai_completition
    handle_completion_error(config['provider'], error)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hans/.vim/plugged/vim-ai/py/utils.py", line 308, in handle_completion_error
    raise error
  File "/home/hans/.vim/plugged/vim-ai/py/complete.py", line 37, in run_ai_completition
    render_text_chunks(text_chunks, append_to_eol=command_type == 'complete')
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hans/.vim/plugged/vim-ai/py/utils.py", line 114, in render_text_chunks
    text = text.lstrip() # trim newlines from the beginning
           ^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'lstrip'

Please let me know if there's anymore information I can provide. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions