Skip to content

GHA-280 Accept Slack Channel IDs (not add "#" in front of them).#140

Merged
nils-werner-sonarsource merged 1 commit intomasterfrom
task/vt/accept-channel-ids
Apr 28, 2026
Merged

GHA-280 Accept Slack Channel IDs (not add "#" in front of them).#140
nils-werner-sonarsource merged 1 commit intomasterfrom
task/vt/accept-channel-ids

Conversation

@Krosovok
Copy link
Copy Markdown
Contributor

Add a regexp validation for Slack channel id format to avoid adding # in front of them. It wouldn't break existing logic with the exception of an edge case when someone explicitly names a channel something like "C1234ABCD" AND passes it without #, which is not very likely based on company convention.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Accept Slack Channel IDs (not add "#" in front of them). GHA-280 Accept Slack Channel IDs (not add "#" in front of them). Apr 28, 2026
@sonar-review-alpha
Copy link
Copy Markdown

sonar-review-alpha Bot commented Apr 28, 2026

Summary

This PR extends the Slack channel input to accept both channel names (e.g., releases) and channel IDs (e.g., C1234ABCDE). The change adds a regex validation in normalize_channel() that detects Slack channel IDs (format: [CDG][A-Z0-9]{8,10}) and passes them through unchanged, rather than prefixing them with #. Channel names continue to work as before. Documentation has been updated to reflect this new capability.

What reviewers should know

Key change: Look at notify_slack.py — the regex pattern _CHANNEL_ID_RE and the updated normalize_channel() function determine how inputs are classified. The pattern is deliberately narrow ([CDG] prefix, 8-10 alphanumeric suffix) to avoid false positives.

Edge case to be aware of: If someone manually names a Slack channel something like "C1234ABCD" (matching the channel ID format) AND passes it without #, it will now be treated as a channel ID and won't get the # prefix. The author notes this is unlikely given typical naming conventions. Worth considering if your organization has any such channels.

Tests to review: The new test cases in test_notify_slack.py cover the three channel ID types (C, D, G) and various ID lengths — good coverage for the regex boundary conditions (8-10 chars after the prefix).


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented Apr 28, 2026

GHA-280

@sonarqubecloud
Copy link
Copy Markdown

sonar-review-alpha[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@nils-werner-sonarsource nils-werner-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM

@nils-werner-sonarsource nils-werner-sonarsource merged commit 7b740e8 into master Apr 28, 2026
12 checks passed
@nils-werner-sonarsource nils-werner-sonarsource deleted the task/vt/accept-channel-ids branch April 28, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants