-
Notifications
You must be signed in to change notification settings - Fork 835
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
files_upload_v2
Doesn't work with user ID's or channel names
#1326
Comments
Hi @nils-soderman thanks for writing in! This is correct, I was able to reproduce this behavior on my local 🥇 Under the hood Ill label this issue as a feature request, this would apply to all implementations of this feature (js, java, python). @seratch I tried using conversations.info to fetch the channel_id from the |
From an old thread I found, it is possible to use conversation.list to go though all the channels and find the It is also possible to use chat.postMessage in order to send a message to the channel using the Both these solutions feel like hacky work arounds |
@nils-soderman @WilliamBergamin channel name was evaluated to be supported at the API endpoint level in the improvements that our teams released to the functions.completeUploadExternal endpoint and channel name support was intentionally omitted. My best understanding for why is because channel names can easily be renamed (with the underlying ID staying the same), channel ID is the more robust way to identify the channel from an app development perspective. Developers relying on channel names as stable leads to more "breaky" apps, and we don't want to set devs up to have unpleasant surprises.
Fair point to bring up about quality of life from a dev perspective, and valuable feedback at that, @nils-soderman. Given that it's highly unlikely channel name support will be added to the api endpoint, and we can certainly take that feedback to see if it makes sense to add support for it at the SDK level, but as @WilliamBergamin, there may not be a robust way to do this. Would love to hear from others using the v2 upload functionality to see if this is a common desire and pain point. Maybe for this, you can have a mapping in your code between channel IDs and names in your project, to get the advantage in readability and code maintenance quality of life when developing, but also use IDs instead. Channel Ids are ultimately the most reliable and stable indicator of a channel that exists, and allow you to get information on that channel (via this endpoint https://api.slack.com/methods/conversations.info). In terms of DM'ing users and supplying user ID in the |
I'm removing the |
Thank you both for the quick responses! Creating a mapping between channel names & ID's makes sense and would indeed solve the issue of not knowing which ID's belong to which channel + as you @srajiang mentioned it'd avoid potential errors in the future due to a channel being renamed. I wasn't aware of the I'll buy the argument for not wanting to support channel names, so unless you would like to keep this issue open to see if anyone else has any opinions, I'd be down close the issue. If anything, since channel names/user ID's was supported with the previous if channel_to_share.startswith(("#", "U")):
raise ValueError("Channel names/user ID's are no longer supported for the `channel` argument, please provide the channel ID instead!") Cheers, |
I don't totally agree, I think it's best to leave the choice. If I want robustness I use a mapping and channel ids, but if I want to do a quick test or stay clear I use channel names. The best option in my opinion is to let the developer choose and also it allows to stay consistent with the rest of the functions. |
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized. |
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number. |
+1. Having to figure out the channel IDs is user unfriendly! |
Slack API files upload |
With the older function
files_upload
you used to be able to use channel names such as "#my_channel" for thechannels
argument.Or use user ID's as the
channels
argument to send the file to a user as a direct message.The new
files_upload_v2
doesn't work with either channel names or user ID's. And seems to only accept channel ID's for thechannel
argument now.So unless I'm missing something there's currently no way to use
files_upload_v2
to send a direct message to a user? it must be posted to a channel.I'd also argue that using channel names in the code is easier to read than channel ID's. Since if I skim through some code I can quickly & easily see what channel a script is logging to. If all I see is an ID I'll have no way of knowing which channel that ID belongs to.
The Slack SDK version
3.19.5
Python runtime version
3.9.7
Steps to reproduce:
Expected result:
Two files would be shared with the channel "my_channel".
Actual result:
files_upload
will send the content as a file, howeverfiles_upload_v2
will respond with:The text was updated successfully, but these errors were encountered: