Skip to content

Fix Slack update_message global URL validation#5296

Open
fallintoplace wants to merge 1 commit into
prometheus:mainfrom
fallintoplace:fix/slack-update-message-global-url
Open

Fix Slack update_message global URL validation#5296
fallintoplace wants to merge 1 commit into
prometheus:mainfrom
fallintoplace:fix/slack-update-message-global-url

Conversation

@fallintoplace

Copy link
Copy Markdown

Fixes #5164.

This keeps Slack update_message validation from dereferencing a missing local api_url during YAML unmarshalling, then validates again after global Slack defaults have been applied. That lets a global chat.postMessage URL work while still rejecting webhook URLs with the existing readable error.

Validation:

  • go test ./config -run 'TestSlackUpdateMessage|TestSlackGlobalAppToken|TestSlackNoAPIURL|TestSlackGlobalAPIURLFile'
  • go test ./config ./notify/slack
  • go test ./config -run TestSlackUpdateMessageWithGlobalAPIURL -count=1
  • go test ./... does not complete in this checkout because generated UI assets and the built alertmanager/amtool acceptance-test binaries are missing.

@fallintoplace fallintoplace requested a review from a team as a code owner June 10, 2026 21:54
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 01f11073-f0d6-4ebd-97cd-17a1f4931251

📥 Commits

Reviewing files that changed from the base of the PR and between 364a227 and 2390ce7.

📒 Files selected for processing (3)
  • config/config.go
  • config/config_test.go
  • config/notifiers.go

📝 Walkthrough

Walkthrough

This PR fixes a nil pointer panic when update_message: true is used in Slack configs without an explicit api_url but with a global slack_api_url. It adds validation to enforce that update_message requires a valid chat.postMessage API URL and integrates this check into config unmarshalling.

Changes

Slack Update Message Validation

Layer / File(s) Summary
Slack update message validation contract and function
config/notifiers.go
Defines slackUpdateMessageAPIURL and slackUpdateMessageError constants for the required chat.postMessage endpoint, and implements validateSlackUpdateMessageURL() to enforce URL validation when UpdateMessage is enabled and APIURL is set.
Config unmarshalling validation integration
config/config.go
Integrates Slack validation into Config.UnmarshalYAML by calling validateSlackUpdateMessageURL() after receiver processing to propagate validation errors during config loading.
Test coverage for global Slack API URL scenarios
config/config_test.go
Updates TestSlackUpdateMessageWebhookURL to use the validation error constant, adds TestSlackUpdateMessageWithGlobalAPIURL to verify global slack_api_url enables update_message, and adds TestSlackUpdateMessageWithGlobalWebhookURL to verify webhook-style URLs trigger validation errors.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing Slack update_message validation to work with global URL configuration.
Description check ✅ Passed The description addresses the linked issue, explains the problem and solution, and provides validation commands, though the release-notes section is empty.
Linked Issues check ✅ Passed The PR successfully addresses issue #5164 by fixing the nil pointer dereference panic and validating update_message after global defaults are applied.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the Slack update_message validation issue; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Panic error on config parsing when update_message: true in slack_configs

1 participant