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: preserve SMTPRequireTLS during default merge (#8478) (#9418)
Pranjul Kalsie5f4f5cc729e
diff --git a/pkg/types/alertmanagertypes/config.go b/pkg/types/alertmanagertypes/config.goindex 1b394fb0ac..b5323ea9cf 100644--- a/pkg/types/alertmanagertypes/config.go+++ b/pkg/types/alertmanagertypes/config.go@@ -93,10 +93,13 @@ func NewConfigFromStoreableConfig(sc *StoreableConfig) (*Config, error) {}func NewDefaultConfig(globalConfig GlobalConfig, routeConfig RouteConfig, orgID string) (*Config, error) {+ // Mergo treats an explicit false as zero-value and overwrites it to true, so we save it in smtpRequireTLS and restore the user-specified value.+ smtpRequireTLS := globalConfig.SMTPRequireTLSerr := mergo.Merge(&globalConfig, config.DefaultGlobalConfig())if err != nil {return nil, err}+ globalConfig.SMTPRequireTLS = smtpRequireTLSroute, err := NewRouteFromRouteConfig(nil, routeConfig)if err != nil {@@ -167,10 +170,13 @@ func (c *Config) CopyWithReset() (*Config, error) {}func (c *Config) SetGlobalConfig(globalConfig GlobalConfig) error {+ // Mergo treats an explicit false as zero-value and overwrites it to true, so we save it in smtpRequireTLS and restore the user-specified value.+ smtpRequireTLS := globalConfig.SMTPRequireTLSerr := mergo.Merge(&globalConfig, config.DefaultGlobalConfig())if err != nil {return err}+ globalConfig.SMTPRequireTLS = smtpRequireTLSc.alertmanagerConfig.Global = &globalConfigc.storeableConfig.Config = string(newRawFromConfig(c.alertmanagerConfig))diff --git a/pkg/types/alertmanagertypes/config_test.go b/pkg/types/alertmanagertypes/config_test.goindex 8d2cabbcb9..2bc6f28aff 100644--- a/pkg/types/alertmanagertypes/config_test.go+++ b/pkg/types/alertmanagertypes/config_test.go@@ -282,3 +282,50 @@ func TestUTF8Validation(t *testing.T) {})}}++func TestNewDefaultConfigPreservesSMTPRequireTLS(t *testing.T) {+ testCases := []struct {+ name string+ globalConfig GlobalConfig+ expect bool+ }{+ {"False", GlobalConfig{SMTPRequireTLS: false}, false},+ {"True", GlobalConfig{SMTPRequireTLS: true}, true},+ }++ for _, tt := range testCases {+ t.Run(tt.name, func(t *testing.T) {+ global := tt.globalConfig+ route := RouteConfig{+ GroupInterval: time.Minute,+ GroupWait: time.Minute,+ RepeatInterval: time.Minute,+ }+ cfg, err := NewDefaultConfig(global, route, "1")++ require.NoError(t, err)+ assert.Equal(t, tt.expect, cfg.alertmanagerConfig.Global.SMTPRequireTLS)+ })+ }+}++func TestSetGlobalConfigPreservesSMTPRequireTLS(t *testing.T) {+ testCases := []struct {+ name string+ globalConfig GlobalConfig+ expect bool+ }{+ {"False", GlobalConfig{SMTPRequireTLS: false}, false},+ {"True", GlobalConfig{SMTPRequireTLS: true}, true},+ }++ for _, tt := range testCases {+ t.Run(tt.name, func(t *testing.T) {+ c := NewConfig(&config.Config{}, "1")+ global := tt.globalConfig+ err := c.SetGlobalConfig(global)+ require.NoError(t, err)+ assert.Equal(t, tt.expect, c.alertmanagerConfig.Global.SMTPRequireTLS)+ })+ }+}