Slack: Subscribe to certain labels only

Created on 27 Feb 2018  ·  43Comments  ·  Source: integrations/slack

I'm a member of a Slack channel dedicated to a specific feature of a repo that covers a wide variety of features. Right now we have an internal Hubot to filter down to a specific label and then post messages to the channel.

It'd be cool if this official integration could replace our internal by allow subscribing to only issues/PRs that have a specific label instead of the entire repo.

subscription feature

Most helpful comment

^ Bump this. When working on a monorepo type project it's useful for feature teams/pods to only subscribe to their specific labels.

All 43 comments

We would love this to be able to filter out Greenkeeper PRs from polluting our Slack channels.

A cursory glance at the code makes it seem like this would be fairly straightforward to implement. If I worked on a PR, would this feature be accepted? What would the preferred command syntax be? /github unsubscribe owner/repo label:[label]? Thanks.

@serhalp

A cursory glance at the code

Can you provide a link to specific lines you had in mind? Or you already started work in this feature?

I have not started on this. But from glancing at the code, it seems that it already fetches the labels for PRs/issues here and here and includes them on the objects passed around. (I think this is just so they can be included in Slack messages).

So, roughly, I was imaging you'd pass in optional label filters to subscribe/unsubscribe here and right around... here (and in the analogous spot for issues) you'd exit early (not send a message) if the PR matches blacklisted labels?

People may want both the ability to whitelist labels and to blacklist labels... Hrm.

^ Bump this. When working on a monorepo type project it's useful for feature teams/pods to only subscribe to their specific labels.

@bkeepers @serhalp any news on this? how to subscribe to PRs with Specified Label only?

Monorepo here as well. This currently makes GH Slack Notifications unusable because of the traffic.

Even for our other repos, a more fine-grained selection of notifications would me this immensely useful, for example only post if a certain tag is set (e.g READY FOR REVIEW) We currently deploy our own bot to work around this limitation: https://pspdfkit.com/blog/2018/reviewbot/

(We cant run our own bot for filtering - that’s too complex)

I've got a similar issue, we have a monorepo for our API/web but we label PRs for our the API that concern our internal tools, it'd be great to have them emit into a specific channel

Same here, we have monorepo as well.

It would be cool to be able to setup something like this on Slack:
/github unsubscribe owner/repo label:[label]

We really need this too.

Also need.

This will be cool

Also need.

Would be very helpful for a monolithic codebase where you want to filter front-end/back-end PRs seperately

Would love this, both for monorepo use cases but also to filter out automatic/bot PRs that become too noisy in some projects (and that all have a specific label)

Our use case is for our designers to be informed on their slack channels when we label an issue with needs:design-review

+1 we also need this....any update as to whether this will be provided?

That would be great! Please make it happen 🤞

+1 for this feature.

+1 This would be extremely helpful and make this integration work better with our teams' workflow.

This is a great idea and my team will definitely benefit from having this option! Bump ^

+1!

➕ 1️⃣

This would be great to have. +1

@cou929 has an open pr for this https://github.com/integrations/slack/pull/797

Yes, I'm also one who strongly wants this function. So a month ago I created a pr #797 .
I would be glad if you give any feedback.

Hey everybody 👋,
thanks for all your input. That is super valuable to help us see the existing demand and to make a good decision about how to implement this feature

First off: It would be great if everybody would upvote the OP instead of adding new comments. When prioritizing potential features, we only take the reaction count of the OP into consideration.

I took a look at @cou929 's PR and the comments above and here are my thoughts:

Whitelist

I think the most requested feature here is about only receiving updates for certain labels only. So it fits nicely into the realm of subscribe. I already mentioned it to @cou929 in the PR, but we hesitate using a JSON-like array syntax and to treat this as JSON, which opens the security risk around deserializing untrusted input.
The PR was already updated and either adding multiple label:xxx label:yyy entries or something similar to that looks like a good approach to me.
I will take a look at the PR soon and then decide what the best path forward is so that we can ship the first iteration of this feature as soon as possible.

Blacklist

There is also a theme around blacklisting like 'everything except X'. (E.g. https://github.com/integrations/slack/issues/384#issuecomment-376593013)
I would like to move that conversation into a dedicated issue so that we focus this issue on what the OP was asking for. If the demand for blacklisting (Use cases like ignoring dependabot/greenkeeper, etc) we can take a look into it too.

Generally, the use case makes a lot of sense to me, but we have to prioritize the requested features.

Hi everybody.
I picked up the work that @cou929 started in #797 and I will push my changes to the existing PR very soon. It should not take much longer to ship the first version of this label feature.

Edit.
Because I had to create a new PR (based on #797), I moved the progress tracking into that PR.
See #911 for all details.

Thank you for your work.

I agreed with @scepticulous ‘s comments. (https://github.com/integrations/slack/pull/797#pullrequestreview-270838189 and https://github.com/integrations/slack/issues/384#issuecomment-520708832 )
I am looking forward to the first version of label feature 😄

Everybody who is interested in sharing their thoughts about a future filter syntax that allows AND/OR combinations, feel free to add your two cents in #913

Filtering by a "required-label" is now possible 🎉 .
I removed the support for AND/OR combinations and multiple labels for now.
As documented in PR #911, the new syntax for adding a required label is:

# Notify events which have `todo` label
/github subscribe owner/repo +label:todo

# You can specify labels which have spaces when enclosed in quotes
/github subscribe owner/repo +label:"help wanted"

# Unsubscribe
/github unsubscribe owner/repo +label:"help wanted"

Hi @scepticulous thanks so much for doing this!

I'm currently running into issues subscribing to labels with whitespace. I'm getting this error
+label:"help is not a valid argument.

when entering the command
/github subscribe owner/repo +label:"help wanted"

I'm currently running into issues subscribing to labels with whitespace. I'm getting this error
+label:"help is not a valid argument.

I assume there is a problem with the quotes or the whitespace. Can you try typing the double quotes " or a single quotes ' manually?
I am planning to add support of all well-known and typical unicode-quotes very soon, but for now we use standard ascii quotes.

Here is my example:

Command
/github subscribe integrations/test +label:"help wanted"

Visual
labels-with-quotes

Thanks again for tackling this! I'm getting the same error using double or single ASCII quotes.

My command was /github subscribe owner/repo +label:“System Integrity” and my error was:

+label:"System is not a valid argument.

FWIW, the repo was private, not sure if that matters, but the GitHub Slack integration can view things in that repo

my new theory is that my github integration does not have the most recent updates. I've tried updating slack, reinstalling the integration, and restarting slack to no avail.

@DeMarko Thanks for sharing your exact command. Your example is actually not using ASCII double-quotes (ASCII 34).

Here is the difference:
/github subscribe owner/repo +label:“System Integrity”
/github subscribe owner/repo +label:"System Integrity"

However, that is hard to spot, confusing and annoying.
So I 🚢 a change that adds supports for the quotes that you are using (and others). PR: #927

In addition to ' and " we now support:

✓ supports '«'
✓ supports '»'
✓ supports '“'
✓ supports '”'
✓ supports '„'
✓ supports '‟'

oh woah! Thanks for spotting that, I had no idea Slack (or maybe my OS?) was doing "smart" Unicode quotes

Hey there, thanks for this awesome feature. Just wondering. Is it entirely impossible to subscribe to multiple labels?

When I run
/github subscribe owner/repo +label:"label a"
/github subscribe owner/repo +label:"label b"
I expected to see both labels added to my subscription. But that didn't work.

Then I tried
/github subscribe owner/repo +label:"label a" +label:"label b"
But that didn't work either. Am I doing something wrong? Is this still on your list?

I would very much like to filter issues on multiple labels. Should I open a new issue to propose this and describe my usecase?

I would expect to get a notification if the required label I'm filtering on, was added after the issue was initially created, e.g.:

  • Configuring a filter for a required label, say, Foo
  • Creating a new issue with no labels set. I don't expect to get a notification (and I don't).
  • Updating the issue by adding the label Foo. I expect to get a notification, but I don't

I am only subscribed to the issues event. But I don't see any other events that would represent the issue metadata getting updated, or a label changed event.

@efung Did you ever find a workaround for this? I am finding the same issue with our workflow.

We're using a github action to set the labels automatically, so they aren't set until after PR creation.

Did you ever find a workaround for this?

No, I haven't.

I would expect to get a notification if the required label I'm filtering on, was added after the issue was initially created, e.g.:

  • Configuring a filter for a required label, say, Foo
  • Creating a new issue with no labels set. I don't expect to get a notification (and I don't).
  • Updating the issue by adding the label Foo. I expect to get a notification, but I don't

I am only subscribed to the issues event. But I don't see any other events that would represent the issue metadata getting updated, or a label changed event.

It seems that labeled/unlabeled events are not triggered at all. For issues and for PRs as well.

Filtering by a "required-label" is now possible 🎉 .
I removed the support for AND/OR combinations and multiple labels for now.
As documented in PR #911, the new syntax for adding a required label is:

# Notify events which have `todo` label
/github subscribe owner/repo +label:todo

# You can specify labels which have spaces when enclosed in quotes
/github subscribe owner/repo +label:"help wanted"

# Unsubscribe
/github unsubscribe owner/repo +label:"help wanted"

Does this support multiple labels, or just one?

Any progress here? I hate adding a"me too" tag here but...

I'm trying to track new issue related to a Repo I DON'T own so I can't add the GitHub Action I found elsewhere that runs at label creation and allows for notice on label if added to the repo issue-label-notifier). This was actually found in a similar request for label subscription in GitHub, that is still open tracing back to 2016... Automatically subscribe to an issue by label or a set of labels

Using the command described HERE I would like to follow ONLY specific label(s) in the Home Automation repo that are associated with the integrations I use....

Sounds simple enough... but to date after searching and reading this thread, I don't see a way to subscribe/follow say home-assistant/core +label:"integration: shelly" +label:"integration: apple_tv" The following command would seem like it SHOULD work IF the command would actually provided notification of ALL NEW AND MODIFIED issues with label(s) found in list...
/github subscribe home-assistant/core +label:"integration: shelly" +label:"integration: apple_tv"

Additional, WHEN this DOES (hopefully) work, can one make changes in the future by simply adding/removing labels from a potential CURRENT/pre-existing subscription list? (i.e. will the following result in 1 or 3 subscribed labels?)
/github subscribe home-assistant/core +label:"integration: shelly" +label:"integration: apple_tv"
/github subscribe home-assistant/core +label:"integration: additional_new_label"

IDEALLY the result of the 2 separate commands above would be a subscription to the repo home-assistant/core for the 3 labels: integration: shelly, apple_tv, additional_new_label

Correspondingly then, one would hope that the 2 commands:
/github subscribe home-assistant/core +label:"integration: shelly" +label:"integration: apple_tv" +label:"integration: additional_new_label"

/github unsubscribe home-assistant/core +label:"integration: additional_new_label"

SHOULD produce a subscription list for home-assistant/core to just 2 labels labels: integration: shelly and integration: apple_tv. Correct?

Thanks for any help here.
--Tom

Was this page helpful?
0 / 5 - 0 ratings