Skip to content

When running 'files_upload' with 'titile=None', TypeError is occurred. #670

@yuji38kwmt

Description

@yuji38kwmt

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 [ ])

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

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

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Version: 2xbugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedweb-client

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions