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

Drop public channel requirement for slack images #54276

Merged
merged 15 commits into from
Mar 7, 2025

Conversation

wotbrew
Copy link
Contributor

@wotbrew wotbrew commented Feb 25, 2025

Previously, before a file could be embedded in a bot post (e.g. images in a dashboard subscription post), it first had to be uploaded to the slack-files-channel. This PR makes it so that the slack-files-channel is no longer necessary, and images can be embedded directly in posts without additional ceremony.

When setting up the slack integration, users no longer need to specify a files channel name. They now only need provide the oauth token.

To be clear, if this PR is merged we will no longer post images to the configured files channel - so if users somehow depend on that (not only the dashboard/alert posts themselves, but the file post) then we might break them. On balance I consider this unlikely enough that the additional complexity required to support any such use cases would not be worth it.

This has a few advantages:

  • Fewer requirements of users to get started with slack, less likely to bounce off due to confusion etc
  • Privacy and security is improved
    e.g say you had a dashboard of employee stats, salary, sick days etc - you might hesitate setting up a subscription because all your slack users would be able to see the dashboard images.
  • Less complexity, tests, documentation needed
  • We could not get private channels to work as a files channel, this bypasses that problem.

downgrades note This is a code only change, the setting is not deleted from existing instances, so if downgraded - the slack integration will start using the files channel again. If a new slack installation (that has never used the files channel) is downgraded, then the files channel will need to be added before the integration works again.

Closes #53319

Closes WRK-59

Description

This is made possible by dropping the legacy slack 'attachment' used for images, and instead utilising the blockkit image element, which permits sending private files directly using the slack_file field.

For large dashboards, more than one slack post will be made per notification, to work around block limits (50 per message).

How to verify

Describe the steps to verify that the changes are working as expected.

  1. Setup a new slack integration

    • admin settings
    • notifications
    • create slack app (I used my own slack developer workspace)
  2. Create a dashboard

  3. Test a subscription

    • click on sharing
    • click on subscriptions
    • click 'send it to slack'
    • choose a channel to post to (private or public is fine)
    • click send to slack now
  4. Observe the post in slack, image is shared directly without posting to a files channel

Checklist

  • Tests have been added/updated to cover changes in this PR.

Sorry, something went wrong.

@wotbrew wotbrew added no-backport Do not backport this PR to any branch .Team/Workflows run-tests labels Feb 25, 2025
@wotbrew wotbrew self-assigned this Feb 25, 2025
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from fef2f7c to 1e1a12a Compare February 25, 2025 17:10
Copy link

trunk-io bot commented Feb 25, 2025

Static BadgeStatic BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
multi-row-create-test The expected result of the `spec-update/do-update!` function does not match the actual result. Logs ↗︎

View Full Report ↗︎Docs

@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch 6 times, most recently from 2773f32 to a974236 Compare February 27, 2025 10:27
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from a974236 to faffe90 Compare February 27, 2025 10:43
@wotbrew wotbrew marked this pull request as ready for review February 28, 2025 09:30
@wotbrew wotbrew requested review from a team as code owners February 28, 2025 09:30
@wotbrew wotbrew requested a review from qnkhuat February 28, 2025 09:31
@qnkhuat
Copy link
Contributor

qnkhuat commented Feb 28, 2025

Testing and I get this error: clojure.lang.ExceptionInfo: Slack API error: missing_scope {:error-code "missing_scope", :message "Slack API error: missing_scope", :response {:ok false, :error "missing_scope", :needed "files:read", :provided "users:read,channels:read,channels:join,files:write,chat:write,chat:write.customize,chat:write.public"}, :url "https://slack.com/api/files.info"} looks like we need to include files:read scope

Copy link
Contributor

@crisptrutski crisptrutski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devils advocating here, but can you imagine any customers being upset at losing the image firehose? Can't imagine a user wanting to be in that channel, but perhaps being used for automation or something.

@qnkhuat
Copy link
Contributor

qnkhuat commented Feb 28, 2025

So I've added the files:read scope and it works.

But I have another issue with sending a big dashboard with 34 cards: Caused by: clojure.lang.ExceptionInfo: Slack API error: invalid_blocks {:error-code "invalid_blocks", :message "Slack API error: invalid_blocks", :response {:ok false, :error "invalid_blocks", :errors ["no more than 50 items allowed [json-pointer:/blocks]"], :response_metadata {:messages ["[ERROR] no more than 50 items allowed [json-pointer:/blocks]"]}}}

For your info, I use the example dashboards at http://localhost:3000/dashboard/1-e-commerce-insights.

I think we need to find a way around this, otherwise this will break some existing integration.

@wotbrew wotbrew marked this pull request as draft March 4, 2025 16:55

Verified

This commit was signed with the committer’s verified signature. The key has expired.
lefou Tobias Roeser
… files channel

This removes the requirement to have a public files channel so share
images or other files in slack bot posts. Simplifying the integration
and lessening requirements to get setup.

It enables the posting of images files directly to public or private
channels without sharing - improving privacy and security.
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from 080868c to 962d55a Compare March 5, 2025 16:04
wotbrew added 2 commits March 5, 2025 16:10

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from 962d55a to b287dbb Compare March 5, 2025 16:11
wotbrew added 5 commits March 5, 2025 16:28
There was an accidental introduction of files.read.

The goal is to preserve the previous behaviour of reusing
completeUploadExternal.

This limits the oauth scope requirements of the bot token.
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from b287dbb to c2a8623 Compare March 5, 2025 16:29
@wotbrew wotbrew force-pushed the WRK-59-slack-images-to-private-channels branch from c2a8623 to 07a2bcc Compare March 5, 2025 17:10
- Its easy to mapv
- (cond) over nested (if)s
- Fix out of date docstring
@wotbrew
Copy link
Contributor Author

wotbrew commented Mar 5, 2025

Devils advocating here, but can you imagine any customers being upset at losing the image firehose? Can't imagine a user wanting to be in that channel, but perhaps being used for automation or something.

I mean, yes - I can imagine it. I think we win on balance?

@wotbrew wotbrew marked this pull request as ready for review March 5, 2025 18:38
@qnkhuat qnkhuat requested a review from a team March 6, 2025 04:54
Copy link
Contributor

@qnkhuat qnkhuat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done!

no scope changes, get passed the block limit.

I do find a mention of slack-channel in docs/configuring-metabase/config-template.md which I think you need to remove.

other than that this looks great to me.

Side note: I think we need to mention in the release note that we'll no longer update images to a channel in case people rely on these.

@wotbrew wotbrew requested a review from filiphric as a code owner March 6, 2025 17:59
@wotbrew wotbrew merged commit 1fc4142 into master Mar 7, 2025
168 checks passed
@wotbrew wotbrew deleted the WRK-59-slack-images-to-private-channels branch March 7, 2025 14:11
uladzimirdev pushed a commit that referenced this pull request Mar 14, 2025
* Prefer slack_file for images, so metabase no longer requires a public files channel

This removes the requirement to have a public files channel so share
images or other files in slack bot posts. Simplifying the integration
and lessening requirements to get setup.

It enables the posting of images files directly to public or private
channels without sharing - improving privacy and security.

* Files channel deprecation note

* Drop slack-files-channel requirement from slack /settings API

* Remove remaining files-channel calls

* Remove files channel input from SlackSetupForm

* Remove slack-files-channel from SettingsManagerSettings

* Remove slack-files-channel from API docs

* Drop files channel configuration guidance

* Remove slack channel prompt/description

* Instead of polling files.read reuse the complete call

There was an accidental introduction of files.read.

The goal is to preserve the previous behaviour of reusing
completeUploadExternal.

This limits the oauth scope requirements of the bot token.

* If more than 50 slack blocks, send using multiple messages

* Escape mkdwn special-processing chars in card links

* Simplify slack attachment uploading

- Its easy to mapv
- (cond) over nested (if)s
- Fix out of date docstring

* Remove slack-files-channel from config-template.md

* Remove metabase_files check from e2e suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch run-tests .Team/Workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slack integration should be able to send images to private channels
3 participants