txthinking/brook · error

Invalid tag

Error message

Invalid tag 

What it means

The --tag flag takes repeated key:value pairs attached to logs. Each value is split on ':' and must yield exactly two parts; otherwise the CLI rejects the whole tag with this error including the offending value. It's a format validation for structured logging labels.

Source

Thrown at cli/brook/main.go:199

				Start: func() error {
					return p.ListenAndServe()
				},
				Stop: func() error {
					return p.Shutdown()
				},
			})
		}
		if c.String("log") != "" {
			if c.String("log") != "console" && !filepath.IsAbs(c.String("log")) {
				return errors.New("--log must be with absolute path")
			}
			var m map[string]string
			if len(c.StringSlice("tag")) > 0 {
				m = make(map[string]string)
				for _, v := range c.StringSlice("tag") {
					l := strings.Split(v, ":")
					if len(l) != 2 {
						return errors.New("Invalid tag " + v)
					}
					m[l[0]] = l[1]
				}
			}
			p, err := logger.NewLogger(m, c.String("log"))
			if err != nil {
				return err
			}
			p.TouchBrook()
			f := df
			df = func() {
				p.Close()
				f()
			}
		}
		if c.String("dialWithDNS") != "" {
			p, err := dialwithdns.NewDialWithDNS(c.String("dialWithDNS"), c.String("dialWithDNSPrefer"))
			if err != nil {

View on GitHub (pinned to 5cd13ef3b1)

Solutions

  1. Provide exactly one colon per tag: --tag env:prod
  2. Remove colons from tag values or choose a colon-free value
  3. Quote the argument in shell if spaces/special chars are involved

Example fix

// before
brook server -l :9999 --tag env:prod:dc1
// after
brook server -l :9999 --tag env:prod --tag dc:dc1
Defensive patterns

Strategy: validation

Validate before calling

for _, t := range tags {
	if strings.Count(t, ":") != 1 {
		return fmt.Errorf("tag must be key:value, got %q", t)
	}
}

Prevention

When it happens

Trigger: Passing --tag with zero or multiple colons, e.g. --tag env or --tag env:prod:zone — strings.Split(v, ":") not returning exactly 2 elements.

Common situations: Tags containing colons in the value (URLs, times); forgetting the value side of the pair; shell quoting issues that mangle the argument.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of txthinking/brook@5cd13ef3b1 (2026-09-06). Data as JSON: /api/errors/d0b051c809f225f1. Report an issue: GitHub.