Python-slack-sdk: When running 'files_upload' with 'titile=None', `TypeError` is occurred.

Created on 7 May 2020  路  2Comments  路  Source: slackapi/python-slack-sdk

Description

When I run 'files_upload' with 'titile=None', TypeError is occurred.

What type of issue is this? (place an x in one of the [ ])

  • [x] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Reproducible in:

slackclient version: 2.5.0

python version: 3.8.1

OS version(s): Xubuntu 18.04

Steps to reproduce:

  1. Run the following python code.
import slack

def upload(token, channels, file, title=None):
    client = slack.WebClient(token=token)
    client.files_upload(channels=channels, file=file, title=titile)

upload(token=MY_TOKEN, channels="#random", file="foo.txt")

Expected result:

I expected that foo.txt is uploaded.

Actual result:

The following error occurred.

  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/slack/web/client.py", line 970, in files_upload
    return self.api_call("files.upload", files={"file": file}, data=kwargs)
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/slack/web/base_client.py", line 171, in api_call
    return self._event_loop.run_until_complete(future)
  File "/home/vagrant/.pyenv/versions/3.8.1/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete
    return future.result()
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/slack/web/base_client.py", line 213, in _send
    res = await self._request(
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/slack/web/base_client.py", line 244, in _request
    async with session.request(http_verb, api_url, **req_args) as res:
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/client.py", line 464, in _request
    req = self._request_class(
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 293, in __init__
    self.update_body_from_data(data)
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 483, in update_body_from_data
    body = FormData(body)()
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/formdata.py", line 148, in __call__
    return self._gen_form_data()
  File "/home/vagrant/.local/share/virtualenvs/slack-primitive-cli-LQxpi-sx/lib/python3.8/site-packages/aiohttp/formdata.py", line 128, in _gen_form_data
    raise TypeError(
TypeError: Can not serialize value type: <class 'NoneType'>
 headers: {}
 value: None
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f8f87bc6820>

Attachments:

When argument titile is removed, the error is not occured.

def upload(token, channels, file):
    client = slack.WebClient(token=token)
    client.files_upload(channels=channels, file=file)
2x bug web-client

All 2 comments

Thanks for taking the time to report this. This is not specific to files.upload API method. I'll fix this for all API calls in the next release.

馃憢 slackclient 2.6.0rc1 is out. The pre-release version contains fixes for your issue described here.
https://pypi.org/project/slackclient/2.6.0rc1/

One week later from now, we'll be releasing version 2.6.0 to PyPI.

If you have a chance, could you try the release candidate version out and let us know your feedback if you find something wrong with it? Thank you very much for being patient with this issue.

Was this page helpful?
0 / 5 - 0 ratings