Move and integrate Receiver configuration#484
Conversation
083b53b to
d56bd27
Compare
This comment has been minimized.
This comment has been minimized.
| if c == nil { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
This shouldn't happen I believe but claude pointed out something here. On upstream, the default config will be returned in such cases here. Maybe we should do the same here
There was a problem hiding this comment.
This is a good point. The default config is set on config unmarshaller level. One thing makes me hesitate to change it is that this is a compatiblity layer: if somehow c is nil, it keeps the semantics. Changing would make this function to be in control what to return.
So, I think let's keep upstream the signle source of configs
| for i, c := range nc.JiraConfigs { | ||
| add("jira", i, c, func(l log.Logger) (notify.Notifier, error) { return jira_v0mimir1.New(c, tmpl, l, httpOps...) }) |
There was a problem hiding this comment.
is there a reason for adding it back?
There was a problem hiding this comment.
It did not exist in v0 configs :( I think we missed it. It exists in our cloud builder, though 🙈
|
|
||
| // New returns a new Discord notifier. | ||
| func New(c *Config, t *template.Template, l log.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) { | ||
| client, err := httpcfg.NewClientFromConfig(*c.HTTPConfig, "discord", httpOpts...) |
There was a problem hiding this comment.
Considering HTTPConfig could be nil, we might want to add a guard clause on the receivers' constructors (or guarantee never nil as mentioned here)
This comment has been minimized.
This comment has been minimized.
c541864 to
8c36c72
Compare
This comment has been minimized.
This comment has been minimized.
d9402cd to
6762c52
Compare
| if !ok { | ||
| return "", errors.New("not a v0mimir config type") | ||
| } | ||
| return itype, nil |
There was a problem hiding this comment.
Integration type detection rejects non-v0 configs
Medium Severity
IntegrationTypeFromMimirTypeReflect no longer derives the integration type from struct names and instead requires the type to exist in v0integrationTypeToIntegrationType. Passing an upstream config.*Config (or any other struct not listed) now errors with “not a v0mimir config type”, which can break code paths still producing upstream receiver config types.
Additional Locations (1)
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (5ba1981c3b)diff --git a/notify/schema.go b/notify/schema.go
--- a/notify/schema.go
+++ b/notify/schema.go
@@ -251,10 +251,10 @@
}
if t.Kind() == reflect.Struct {
itype, ok := v0integrationTypeToIntegrationType[t]
- if !ok {
- return "", errors.New("not a v0mimir config type")
+ if ok {
+ return itype, nil
}
- return itype, nil
+ return IntegrationTypeFromString(strings.ToLower(strings.TrimSuffix(t.Name(), "Config")))
}
if t.Kind() == reflect.Ptr {
return IntegrationTypeFromMimirTypeReflect(t.Elem()) |



Description
This pull request includes the following changes:
Receivercomponent to align with the updated architecture.HTTPClientConfig.HTTPClientConfig.Checklist
Note
Medium Risk
Touches core receiver config types, HTTP client configuration, and integration construction/validation; regressions could break notification delivery or config compatibility across many integrations.
Overview
Switches
PostableApiReceiverand related alertmanager definition/config plumbing from Prometheusconfig.Receiverto a newdefinition.Receiverthat directly embeds Grafanav0mimir1receiver config types, with stricter YAML validation (e.g., required receivername).Introduces a dedicated
http/v0mimir1HTTP client config package (plus compat converters to/from Prometheuscommon/config) and updates compat loading, merge/JSON handling, and Mimir validation to use this converted HTTP config for all v0 integrations.Adds full upstream-compat conversion helpers (
definition/compat/receiver_compat.go) and migrates Mimir integration building to Grafanav0mimir1notifier implementations, including newly addedjirasupport; tests and notify test helpers are updated accordingly, and dependencies are adjusted ingo.mod/go.sum.Written by Cursor Bugbot for commit 6762c52. This will update automatically on new commits. Configure here.