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
chore(channel-receivers): relax channel validations (#13008)
praneeth-signoz81d024dfc8d9
diff --git a/pkg/types/alertmanagertypes/channel_googlechat.go b/pkg/types/alertmanagertypes/channel_googlechat.goindex b7e4a986cc..59afbf585a 100644--- a/pkg/types/alertmanagertypes/channel_googlechat.go+++ b/pkg/types/alertmanagertypes/channel_googlechat.go@@ -1,9 +1,6 @@package alertmanagertypesimport (- "net/url"- "strings"-"github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/valuer""github.com/prometheus/alertmanager/config"@@ -89,15 +86,5 @@ func (c *GoogleChatReceiverConfig) UnmarshalYAML(unmarshal func(any) error) erroif c.WebhookURL == nil {return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "google chat webhook_url is required")}- u, err := url.Parse(c.WebhookURL.String())- if err != nil {- return errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "invalid google chat webhook_url: %v", err)- }- if u.Scheme != "https" {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "google chat webhook_url must use https")- }- if strings.ToLower(u.Hostname()) != "chat.googleapis.com" {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "google chat webhook_url must use chat.googleapis.com")- }return nil}diff --git a/pkg/types/alertmanagertypes/channel_googlechat_test.go b/pkg/types/alertmanagertypes/channel_googlechat_test.goindex f81476d8fd..c3cebac284 100644--- a/pkg/types/alertmanagertypes/channel_googlechat_test.go+++ b/pkg/types/alertmanagertypes/channel_googlechat_test.go@@ -13,8 +13,6 @@ func TestNewReceiverGoogleChatWebhookURL(t *testing.T) {wantErr bool}{{"valid", `{"name":"gc","googlechat_configs":[{"webhook_url":"https://chat.googleapis.com/v1/spaces/AAA/messages?key=k&token=t"}]}`, false},- {"http scheme rejected", `{"name":"gc","googlechat_configs":[{"webhook_url":"http://chat.googleapis.com/v1/spaces/x/messages"}]}`, true},- {"wrong host rejected", `{"name":"gc","googlechat_configs":[{"webhook_url":"https://example.com/x"}]}`, true},{"missing webhook_url", `{"name":"gc","googlechat_configs":[{"title":"x"}]}`, true},}for _, c := range cases {diff --git a/pkg/types/alertmanagertypes/channel_incidentio.go b/pkg/types/alertmanagertypes/channel_incidentio.goindex 65d86f670e..6855f34427 100644--- a/pkg/types/alertmanagertypes/channel_incidentio.go+++ b/pkg/types/alertmanagertypes/channel_incidentio.go@@ -1,8 +1,6 @@package alertmanagertypesimport (- "fmt"- "net/url""strings""github.com/SigNoz/signoz/pkg/errors"@@ -64,11 +62,6 @@ func newChannelIncidentIOConfigFromReceiver(name string, receiver *Receiver) (Ch}, nil}-// incidentIOEventsPathPrefix is the path of incident.io's HTTP alert source-// endpoint (Alert Events V2 API). The full URL is per-source:-// https://api.incident.io/v2/alert_events/http/<source_config_id>.-const incidentIOEventsPathPrefix = "/v2/alert_events/http/"-// The description is markdown; incident.io renders it natively. The templates// mirror Google Chat / Jira / JSM for a consistent default across channels.const (@@ -132,19 +125,8 @@ func (c *IncidentIOReceiverConfig) UnmarshalYAML(unmarshal func(any) error) erroc.Description = DefaultIncidentIODescriptionTemplate}- // Values are stored and sent exactly as configured, so anything that is- // not already canonical is rejected rather than rewritten.- if c.URL != strings.TrimSpace(c.URL) {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "incidentio url must not have leading or trailing whitespace")- }- u, err := url.Parse(c.URL)- if c.URL == "" || err != nil || u.Scheme != "https" || u.Host == "" ||- !strings.Contains(u.Path, incidentIOEventsPathPrefix) ||- strings.HasSuffix(u.Path, incidentIOEventsPathPrefix) {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, fmt.Sprintf("incidentio url must be an alert events URL (https://api.incident.io%s<source_config_id>)", incidentIOEventsPathPrefix))- }- if strings.HasSuffix(c.URL, "/") {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "incidentio url must not end with a trailing slash")+ if c.URL == "" {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "incidentio url is required")}token := string(c.Token)diff --git a/pkg/types/alertmanagertypes/channel_incidentio_test.go b/pkg/types/alertmanagertypes/channel_incidentio_test.goindex bbdaed3c02..1d8addf2a0 100644--- a/pkg/types/alertmanagertypes/channel_incidentio_test.go+++ b/pkg/types/alertmanagertypes/channel_incidentio_test.go@@ -45,11 +45,6 @@ func TestIncidentIOReceiverConfigValidation(t *testing.T) {json string}{{"missing url", `{"name":"incio","incidentio_configs":[{"token":"k"}]}`},- {"http url", `{"name":"incio","incidentio_configs":[{"url":"http://api.incident.io/v2/alert_events/http/abc","token":"k"}]}`},- {"not an alert events url", `{"name":"incio","incidentio_configs":[{"url":"https://api.incident.io/v2/incidents","token":"k"}]}`},- {"missing source config id", `{"name":"incio","incidentio_configs":[{"url":"https://api.incident.io/v2/alert_events/http/","token":"k"}]}`},- {"trailing slash", fmt.Sprintf(`{"name":"incio","incidentio_configs":[{"url":"%s/","token":"k"}]}`, testIncidentIOURL)},- {"whitespace around url", fmt.Sprintf(`{"name":"incio","incidentio_configs":[{"url":" %s ","token":"k"}]}`, testIncidentIOURL)},{"missing token", fmt.Sprintf(`{"name":"incio","incidentio_configs":[{"url":"%s"}]}`, testIncidentIOURL)},{"bearer prefixed token", fmt.Sprintf(`{"name":"incio","incidentio_configs":[{"url":"%s","token":"Bearer tok-123"}]}`, testIncidentIOURL)},{"lowercase bearer prefixed token", fmt.Sprintf(`{"name":"incio","incidentio_configs":[{"url":"%s","token":"bearer tok-123"}]}`, testIncidentIOURL)},diff --git a/pkg/types/alertmanagertypes/channel_jira.go b/pkg/types/alertmanagertypes/channel_jira.goindex 1fd030eb2b..87ea3a4070 100644--- a/pkg/types/alertmanagertypes/channel_jira.go+++ b/pkg/types/alertmanagertypes/channel_jira.go@@ -2,7 +2,6 @@ package alertmanagertypesimport ("fmt"- "net/url""strings""time"@@ -153,7 +152,6 @@ const defaultJiraReopenDuration = model.Duration(3 * 24 * time.Hour)// Service accounts authenticate against the api.atlassian.com gateway (keyed by// cloud id) instead of the site host; they are identified by their email domain.const (- jiraCloudHostSuffix = ".atlassian.net"jiraServiceAccountEmailDomain = "@serviceaccount.atlassian.com"jiraGatewayBaseURL = "https://api.atlassian.com/ex/jira/")@@ -204,11 +202,13 @@ func (c *JiraReceiverConfig) UnmarshalYAML(unmarshal func(any) error) error {if c.ReopenDuration <= 0 {c.ReopenDuration = defaultJiraReopenDuration}+// sub-minute windows truncate to 0 in the reopen JQL and silently disable// reopening, so reject them.if c.ReopenDuration < model.Duration(time.Minute) {return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "jira reopen_duration must be at least 1m")}+if c.Summary == "" {c.Summary = DefaultJiraSummaryTemplate}@@ -216,19 +216,9 @@ func (c *JiraReceiverConfig) UnmarshalYAML(unmarshal func(any) error) error {c.Description = DefaultJiraDescriptionTemplate}- // Values are stored and sent exactly as configured, so anything that is- // not already canonical is rejected rather than rewritten.- if c.Site != strings.TrimSpace(c.Site) {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "jira site must not have leading or trailing whitespace")- }- u, err := url.Parse(c.Site)- if c.Site == "" || err != nil || u.Scheme != "https" || !strings.HasSuffix(strings.ToLower(u.Hostname()), jiraCloudHostSuffix) {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, fmt.Sprintf("jira site must be a Jira Cloud URL (https://<site>%s)", jiraCloudHostSuffix))+ if c.Site == "" {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "jira site is required")}- if strings.HasSuffix(c.Site, "/") {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "jira site must not end with a trailing slash")- }-if c.Project == "" {return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "jira project is required")}diff --git a/pkg/types/alertmanagertypes/channel_jira_test.go b/pkg/types/alertmanagertypes/channel_jira_test.goindex 4ca17163ba..8fbdf83215 100644--- a/pkg/types/alertmanagertypes/channel_jira_test.go+++ b/pkg/types/alertmanagertypes/channel_jira_test.go@@ -11,19 +11,19 @@ import ("github.com/stretchr/testify/require")-func jiraReceiverJSON(site, project, issueType string, withAuth bool) string {+func jiraReceiverJSON(project, issueType string, withAuth bool) string {auth := ""if withAuth {auth = `,"http_config":{"basic_auth":{"username":"[email protected]","password":"token"}}`}return fmt.Sprintf(- `{"name":"jira","jira_configs":[{"site":%q,"project":%q,"issue_type":%q%s}]}`,- site, project, issueType, auth,+ `{"name":"jira","jira_configs":[{"site":"https://acme.atlassian.net","project":%q,"issue_type":%q%s}]}`,+ project, issueType, auth,)}func TestJiraReceiverConfigDefaults(t *testing.T) {- r, err := NewReceiver(jiraReceiverJSON("https://acme.atlassian.net", "KAN", "Task", true))+ r, err := NewReceiver(jiraReceiverJSON("KAN", "Task", true))require.NoError(t, err)require.Len(t, r.JiraConfigs, 1)@@ -93,17 +93,10 @@ func TestJiraReceiverConfigValidation(t *testing.T) {json string}{{"missing site", `{"name":"j","jira_configs":[{"project":"KAN","issue_type":"Task","http_config":{"basic_auth":{"username":"e","password":"t"}}}]}`},- {"http site", jiraReceiverJSON("http://acme.atlassian.net", "KAN", "Task", true)},- {"non-cloud host", jiraReceiverJSON("https://jira.acme.com", "KAN", "Task", true)},- {"lookalike host suffix", jiraReceiverJSON("https://www.iamnotatlassian.net", "KAN", "Task", true)},- {"bare atlassian.net", jiraReceiverJSON("https://atlassian.net", "KAN", "Task", true)},- {"trailing slash site", jiraReceiverJSON("https://acme.atlassian.net/", "KAN", "Task", true)},- {"padded site", jiraReceiverJSON(" https://acme.atlassian.net ", "KAN", "Task", true)},- {"missing project", jiraReceiverJSON("https://acme.atlassian.net", "", "Task", true)},- {"missing issue_type", jiraReceiverJSON("https://acme.atlassian.net", "KAN", "", true)},- {"missing basic auth", jiraReceiverJSON("https://acme.atlassian.net", "KAN", "Task", false)},+ {"missing project", jiraReceiverJSON("", "Task", true)},+ {"missing issue_type", jiraReceiverJSON("KAN", "", true)},+ {"missing basic auth", jiraReceiverJSON("KAN", "Task", false)},{"invalid reopen_duration format", `{"name":"j","jira_configs":[{"site":"https://acme.atlassian.net","project":"KAN","issue_type":"Task","reopen_duration":"3days","http_config":{"basic_auth":{"username":"e","password":"t"}}}]}`},- {"sub-minute reopen_duration", `{"name":"j","jira_configs":[{"site":"https://acme.atlassian.net","project":"KAN","issue_type":"Task","reopen_duration":"30s","http_config":{"basic_auth":{"username":"e","password":"t"}}}]}`},}for _, c := range cases {t.Run(c.name, func(t *testing.T) {diff --git a/pkg/types/alertmanagertypes/channelconvertors_test.go b/pkg/types/alertmanagertypes/channelconvertors_test.goindex edf76df1eb..850cfd2bbc 100644--- a/pkg/types/alertmanagertypes/channelconvertors_test.go+++ b/pkg/types/alertmanagertypes/channelconvertors_test.go@@ -4,7 +4,6 @@ import ("reflect""testing"- "github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/valuer""github.com/prometheus/alertmanager/config"commoncfg "github.com/prometheus/common/config"@@ -368,26 +367,6 @@ func TestPostableChannelToReceiverRoundTripsWebhookAuthModes(t *testing.T) {}}-// The SigNoz notifiers validate in their UnmarshalYAML, which ToReceiver reaches-// only through the defaulting round-trip. A spec that passes Validate can still-// be rejected there, and the request has to fail as invalid input rather than as-// an internal error.-func TestPostableChannelToReceiverReportsNotifierValidationAsInvalidInput(t *testing.T) {- postable := PostableNotificationChannel{- Name: "channel",- DisplayName: "channel",- Config: ChannelConfig{Kind: ChannelKindIncidentIO, Spec: &ChannelIncidentIOConfig{- URL: "https://api.incident.io/v2/incidents", Token: "token",- Title: valuer.MustNewUnsetOrNonEmptyString("incidentio title"), Description: valuer.MustNewUnsetOrNonEmptyString("incidentio description"),- }},- }- require.NoError(t, postable.Validate())-- _, err := postable.ToReceiver()- require.Error(t, err)- assert.True(t, errors.Ast(err, errors.TypeInvalidInput), "got %v", err)-}-// rejectUnsupportedHTTPConfig enumerates the fields it rejects, so one added// upstream would pass unnoticed and be dropped on read. Pinning the counts turns// a dependency bump into a failing test rather than silent data loss.diff --git a/tests/integration/tests/alertmanager/04_notification_channels_v2.py b/tests/integration/tests/alertmanager/04_notification_channels_v2.pyindex b15366c310..d4fb9a5347 100644--- a/tests/integration/tests/alertmanager/04_notification_channels_v2.py+++ b/tests/integration/tests/alertmanager/04_notification_channels_v2.py@@ -336,10 +336,7 @@ def test_create_rejects_a_duplicate_display_name(pytest.param({"name": "webhook-both-auth", "config": {"kind": "webhook", "spec": {"url": "https://webhook.test/hook", "username": "u", "password": "p", "bearerToken": "t"}}}, id="webhook_basic_auth_with_bearer_token"),# The last three reach the notifier's own validation rather than the# spec's, so they assert it still surfaces as a 400 through v2.- pytest.param({"name": "jira-server-site", "config": {"kind": "jira", "spec": {"site": "https://jira.acme.com", "project": "OPS", "issueType": "Bug", "email": "[email protected]", "apiToken": "t", "summary": "Alert", "description": "body"}}}, id="jira_site_not_jira_cloud"),- pytest.param(- {"name": "jira-short-reopen", "config": {"kind": "jira", "spec": {"site": "https://acme.atlassian.net", "project": "OPS", "issueType": "Bug", "email": "[email protected]", "apiToken": "t", "summary": "Alert", "description": "body", "reopenDuration": "30s"}}}, id="jira_reopen_duration_below_a_minute"- ),+ pytest.param({"name": "jira-short-reopen", "config": {"kind": "jira", "spec": {"site": "https://acme.atlassian.net", "project": "OPS", "issueType": "Bug", "email": "[email protected]", "apiToken": "t", "summary": "Alert", "description": "body", "reopenDuration": "30s"}}}, id="jira_reopen_duration_below_a_minute"),pytest.param({"name": "incidentio-bearer", "config": {"kind": "incidentio", "spec": {"url": "https://api.incident.io/v2/alert_events/http/01ABCDEF", "token": "Bearer incidentio-token", "title": "Alert", "description": "body"}}}, id="incidentio_token_with_bearer_prefix"),pytest.param({"name": "slack-empty-title", "config": {"kind": "slack", "spec": {"apiUrl": "https://hooks.slack.test/services/T/B/X", "title": ""}}}, id="empty_string_on_a_defaulted_field"),pytest.param({"name": "jsmops-empty-tags", "config": {"kind": "jsmops", "spec": {"apiKey": "jsm-api-key", "tags": ""}}}, id="empty_string_on_a_defaulted_signoz_field"),