diff --git a/CHANGELOG.md b/CHANGELOG.md index e7cb641961..13336c870f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,8 @@ Main (unreleased) - Updated `prometheus.write.queue` to fix issue with TTL comparing different scales of time. (@mattdurham) +- Fixed a crash when updating the configuration of `remote.http`. (@kinolaev) + ### Other changes - Change the stability of the `livedebugging` feature from "experimental" to "generally available". (@wildum) diff --git a/internal/runtime/internal/importsource/import_http.go b/internal/runtime/internal/importsource/import_http.go index f8cbfd469b..815748f8f6 100644 --- a/internal/runtime/internal/importsource/import_http.go +++ b/internal/runtime/internal/importsource/import_http.go @@ -66,17 +66,18 @@ func (im *ImportHTTP) Evaluate(scope *vm.Scope) error { if err := im.eval.Evaluate(scope, &arguments); err != nil { return fmt.Errorf("decoding configuration: %w", err) } + remoteHttpArguments := remote_http.Arguments{ + URL: arguments.URL, + PollFrequency: arguments.PollFrequency, + PollTimeout: arguments.PollTimeout, + Method: arguments.Method, + Headers: arguments.Headers, + Body: arguments.Body, + Client: arguments.Client, + } if im.managedRemoteHTTP == nil { var err error - im.managedRemoteHTTP, err = remote_http.New(im.managedOpts, remote_http.Arguments{ - URL: arguments.URL, - PollFrequency: arguments.PollFrequency, - PollTimeout: arguments.PollTimeout, - Method: arguments.Method, - Headers: arguments.Headers, - Body: arguments.Body, - Client: arguments.Client, - }) + im.managedRemoteHTTP, err = remote_http.New(im.managedOpts, remoteHttpArguments) if err != nil { return fmt.Errorf("creating http component: %w", err) } @@ -88,7 +89,7 @@ func (im *ImportHTTP) Evaluate(scope *vm.Scope) error { } // Update the existing managed component - if err := im.managedRemoteHTTP.Update(arguments); err != nil { + if err := im.managedRemoteHTTP.Update(remoteHttpArguments); err != nil { return fmt.Errorf("updating component: %w", err) } im.arguments = arguments