SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: read Bearer/bearer/BEARER properly in v2 for webhook notification channels (#12890)
Naman Vermad1a382945ce2
diff --git a/pkg/types/alertmanagertypes/channelconfig.go b/pkg/types/alertmanagertypes/channelconfig.goindex c6d1a0a3c8..1f17e5cb23 100644--- a/pkg/types/alertmanagertypes/channelconfig.go+++ b/pkg/types/alertmanagertypes/channelconfig.go@@ -1014,7 +1014,7 @@ func rejectHTTPBasicAuthBeyondPassword(channelName string, httpConfig *commoncfgbasicAuth := httpConfig.BasicAuthif *basicAuth != (commoncfg.BasicAuth{Username: basicAuth.Username, Password: basicAuth.Password}) {- return errors.NewInvalidInputf(ErrCodeAlertmanagerChannelInvalid, "channel %q sets http_config.basic_auth, which is not supported", channelName)+ return errors.NewInvalidInputf(ErrCodeAlertmanagerChannelInvalid, "channel %q sets http_config.basic_auth with fields other than username and password, which is not supported", channelName)}return nil@@ -1026,8 +1026,8 @@ func rejectHTTPAuthorizationBeyondBearer(channelName string, httpConfig *commonc}authorization := httpConfig.Authorization- if *authorization != (commoncfg.Authorization{Type: bearerAuthorizationType, Credentials: authorization.Credentials}) {- return errors.NewInvalidInputf(ErrCodeAlertmanagerChannelInvalid, "channel %q sets http_config.authorization, which is not supported", channelName)+ if !strings.EqualFold(authorization.Type, bearerAuthorizationType) || *authorization != (commoncfg.Authorization{Type: authorization.Type, Credentials: authorization.Credentials}) {+ return errors.NewInvalidInputf(ErrCodeAlertmanagerChannelInvalid, "channel %q sets http_config.authorization with fields other than a bearer token, which is not supported", channelName)}return nildiff --git a/pkg/types/alertmanagertypes/channelconvertors_test.go b/pkg/types/alertmanagertypes/channelconvertors_test.goindex f682b88f0a..c7360ed9a1 100644--- a/pkg/types/alertmanagertypes/channelconvertors_test.go+++ b/pkg/types/alertmanagertypes/channelconvertors_test.go@@ -542,3 +542,42 @@ func TestChannelToPostableChannelRejectsUnrepresentableChannels(t *testing.T) {})}}++// The HTTP auth scheme is case-insensitive (RFC 7235) and Alertmanager sends+// the stored spelling verbatim, so a hand-written receiver may carry any casing.+func TestChannelToPostableChannelReadsWebhookBearerSchemeCaseInsensitively(t *testing.T) {+ sendResolved := config.DefaultWebhookConfig.VSendResolved++ testCases := []struct {+ name string+ storedChannelData string+ expectedWebhookSpec *ChannelWebhookConfig+ }{+ {+ name: "CanonicalBearer",+ storedChannelData: `{"name":"hook","webhook_configs":[{"send_resolved":true,"url":"https://a","http_config":{"authorization":{"type":"Bearer","credentials":"tok"},"follow_redirects":true,"enable_http2":true}}]}`,+ expectedWebhookSpec: &ChannelWebhookConfig{SendResolved: &sendResolved, URL: "https://a", BearerToken: "tok"},+ },+ {+ name: "LowercaseBearer",+ storedChannelData: `{"name":"hook","webhook_configs":[{"send_resolved":true,"url":"https://b","http_config":{"authorization":{"type":"bearer","credentials":"lower"},"follow_redirects":true,"enable_http2":true}}]}`,+ expectedWebhookSpec: &ChannelWebhookConfig{SendResolved: &sendResolved, URL: "https://b", BearerToken: "lower"},+ },+ {+ name: "UppercaseBearer",+ storedChannelData: `{"name":"hook","webhook_configs":[{"send_resolved":true,"url":"https://c","http_config":{"authorization":{"type":"BEARER","credentials":"upper"},"follow_redirects":true,"enable_http2":true}}]}`,+ expectedWebhookSpec: &ChannelWebhookConfig{SendResolved: &sendResolved, URL: "https://c", BearerToken: "upper"},+ },+ }++ for _, testCase := range testCases {+ t.Run(testCase.name, func(t *testing.T) {+ channel := Channel{DisplayName: "hook", Data: testCase.storedChannelData}++ postable, err := channel.toPostableNotificationChannel()+ require.NoError(t, err)+ assert.Equal(t, ChannelKindWebhook, postable.Config.Kind)+ assert.Equal(t, testCase.expectedWebhookSpec, postable.Config.Spec)+ })+ }+}