diff --git a/docs/changelog/CHANGELOG.md b/docs/changelog/CHANGELOG.md index a36f4bb5d..c8808af14 100644 --- a/docs/changelog/CHANGELOG.md +++ b/docs/changelog/CHANGELOG.md @@ -51,6 +51,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/). * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/metricsql/): consistently return the first non-`NaN` value from [`range_first`](https://docs.victoriametrics.com/metricsql/#range_first) function across all the returned data points. Previously `NaN` data points weren't replaced with the first non-`NaN` value. * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/metricsql/): consistently return the last non-`NaN` value from [`range_last`](https://docs.victoriametrics.com/metricsql/#range_last) function across all the returned data points. Previously `NaN` data points weren't replaced with the last non-`NaN` value. * BUGFIX: all VictoriaMetrics components: increase default value of `-loggerMaxArgLen` cmd-line flag from 1000 to 5000. This should improve visibility on errors produced by very long queries. +* BUGFIX: all VictoriaMetrics components: trim trailing spaces when reading content from `*.passwordFile` and similar flags. It reverts changes introduced at [v1.102.0-rc2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.102.0-rc2) release. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6986) for details. ## [v1.103.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.103.0) diff --git a/lib/flagutil/password_test.go b/lib/flagutil/password_test.go index e7a03c2a1..8a9583406 100644 --- a/lib/flagutil/password_test.go +++ b/lib/flagutil/password_test.go @@ -32,7 +32,7 @@ func TestPassword(t *testing.T) { // read the password from file by relative path localPassFile := "testdata/password.txt" - expectedPassword = "foo-bar-baz\n\n\n" + expectedPassword = "foo-bar-baz" path := "file://" + localPassFile if err := p.Set(path); err != nil { t.Fatalf("cannot set password to file: %s", err) @@ -52,7 +52,7 @@ func TestPassword(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %s", err) } - expectedPassword = "foo-bar-baz\n\n\n" + expectedPassword = "foo-bar-baz" path = "file://" + localPassFile if err := p.Set(path); err != nil { t.Fatalf("unexpected error: %s", err) diff --git a/lib/fs/fscore/fscore.go b/lib/fs/fscore/fscore.go index 03cc37562..b67028203 100644 --- a/lib/fs/fscore/fscore.go +++ b/lib/fs/fscore/fscore.go @@ -7,6 +7,8 @@ import ( "net/url" "os" "path/filepath" + "strings" + "unicode" ) // ReadPasswordFromFileOrHTTP reads password for the give path. @@ -17,7 +19,8 @@ func ReadPasswordFromFileOrHTTP(path string) (string, error) { if err != nil { return "", err } - return string(data), nil + pass := strings.TrimRightFunc(string(data), unicode.IsSpace) + return pass, nil } // ReadFileOrHTTP reads path either from local filesystem or from http if path starts with http or https.