Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-list list-like parameters passed to API call are not serialized to JSON #337

Closed
4 of 9 tasks
jstlaurent opened this issue Jul 18, 2018 · 3 comments
Closed
4 of 9 tasks
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 1x

Comments

@jstlaurent
Copy link

Description

When sending a list-like parameter to an API method (attachments to chat.postMessage, for example), only actual list and dict are serialized to JSON. Sending a tuple is not serialized and the attachments are disregarded by the Slack API.

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

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: 1.2.1

python version: 2.7.14

OS version(s): macOS 10.13.5

Steps to reproduce:

  1. Instantiate a SlackClient with a proper token
  2. Call the api_call method on the client, for the chat.postMessage API endpoint, with the following parameters:
client.api_call(
    'chat.postMessage', 
    channel='<valid_channel_id>', 
    text='Message text', 
    attachments=(
        {
            "text": "First attachment",
            "color": "#ffa600",
        }, 
        {
            "text": "Second attachment",
            "color": "#ffa600",
        }
    )
)
  1. Read the message posted

Expected result:

The message is displayed with two attachments.

Actual result:

Only the message text is displayed.

Potential fix:

I believe the type checking done in slackrequest.py could be loosened so that tuples and other iterables could be supported as well.

@Roach Roach added the bug label Aug 6, 2018
@Roach
Copy link
Contributor

Roach commented Aug 6, 2018

Thanks for catching this. We'll add tuple to the list or attachment iterables.

https://github.com/slackapi/python-slackclient/blob/master/slackclient/slackrequest.py#L93-L96

Can you think of any more data types that should be in that list? 🤔

@jstlaurent
Copy link
Author

Thanks for getting back to me! I meant to send a PR along with the report, but things got a bit hectic. Sorry it took me so long. I added support for tuples, sets and generators in the PR. Let me know if that's too much and I'll narrow it down.

@RodneyU215 RodneyU215 removed the bug label Jun 4, 2019
@seratch seratch added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 1x labels Apr 28, 2020
@seratch
Copy link
Member

seratch commented Apr 28, 2020

This project no longer supports version 1.x as we've described here. Allow me to close this now.

@seratch seratch closed this as completed Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 1x
Projects
None yet
Development

No branches or pull requests

4 participants