From a5df1e2525c51a9e2840675d9b91d6bb3cdee603 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 17 Aug 2023 13:26:10 +0200 Subject: [PATCH] lib/envflag: do not allow unsupported form for boolean command-line flags in the form `-boolFlag value` Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845 --- docs/CHANGELOG.md | 1 + lib/envflag/envflag.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cb9493c57..8572bf17a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,7 @@ The following tip changes can be tested by building VictoriaMetrics components f ## v1.87.x long-time support release (LTS) +* BUGFIX: do not allow starting VictoriaMetrics components with improperly set boolean command-line flags in the form `-boolFlagName value`, since this leads to silent incomplete flags' parsing. This form should be replaced with `-boolFlagName=value`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845). * BUGFIX: properly replace `:` chars in label names with `_` when `-usePromCompatibleNaming` command-line flag is passed to `vmagent`, `vminsert` or single-node VictoriaMetrics. This addresses [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3113#issuecomment-1275077071). * BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): correctly check if specified `-dst` belongs to specified `-storageDataPath`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4837). diff --git a/lib/envflag/envflag.go b/lib/envflag/envflag.go index 598cf4dc0..39dc44d5f 100644 --- a/lib/envflag/envflag.go +++ b/lib/envflag/envflag.go @@ -32,6 +32,11 @@ func ParseFlagSet(fs *flag.FlagSet, args []string) { // Do not use lib/logger here, since it is uninitialized yet. log.Fatalf("cannot parse flags %q: %s", args, err) } + if fs.NArg() > 0 { + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845 + log.Fatalf("unprocessed command-line args left: %s; the most likely reason is missing `=` between boolean flag name and value; "+ + "see https://pkg.go.dev/flag#hdr-Command_line_flag_syntax", fs.Args()) + } if !*enable { return }