{"record":{"id":"d0b051c809f225f1","repo":"txthinking/brook","slug":"invalid-tag","errorCode":null,"errorMessage":"Invalid tag ","messagePattern":"Invalid tag ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/brook/main.go","lineNumber":199,"sourceCode":"\t\t\t\tStart: func() error {\n\t\t\t\t\treturn p.ListenAndServe()\n\t\t\t\t},\n\t\t\t\tStop: func() error {\n\t\t\t\t\treturn p.Shutdown()\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif c.String(\"log\") != \"\" {\n\t\t\tif c.String(\"log\") != \"console\" && !filepath.IsAbs(c.String(\"log\")) {\n\t\t\t\treturn errors.New(\"--log must be with absolute path\")\n\t\t\t}\n\t\t\tvar m map[string]string\n\t\t\tif len(c.StringSlice(\"tag\")) > 0 {\n\t\t\t\tm = make(map[string]string)\n\t\t\t\tfor _, v := range c.StringSlice(\"tag\") {\n\t\t\t\t\tl := strings.Split(v, \":\")\n\t\t\t\t\tif len(l) != 2 {\n\t\t\t\t\t\treturn errors.New(\"Invalid tag \" + v)\n\t\t\t\t\t}\n\t\t\t\t\tm[l[0]] = l[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\tp, err := logger.NewLogger(m, c.String(\"log\"))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tp.TouchBrook()\n\t\t\tf := df\n\t\t\tdf = func() {\n\t\t\t\tp.Close()\n\t\t\t\tf()\n\t\t\t}\n\t\t}\n\t\tif c.String(\"dialWithDNS\") != \"\" {\n\t\t\tp, err := dialwithdns.NewDialWithDNS(c.String(\"dialWithDNS\"), c.String(\"dialWithDNSPrefer\"))\n\t\t\tif err != nil {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/cli/brook/main.go#L181-L217","documentation":"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.","triggerScenarios":"Passing --tag with zero or multiple colons, e.g. --tag env or --tag env:prod:zone — strings.Split(v, \":\") not returning exactly 2 elements.","commonSituations":"Tags containing colons in the value (URLs, times); forgetting the value side of the pair; shell quoting issues that mangle the argument.","solutions":["Provide exactly one colon per tag: --tag env:prod","Remove colons from tag values or choose a colon-free value","Quote the argument in shell if spaces/special chars are involved"],"exampleFix":"// before\nbrook server -l :9999 --tag env:prod:dc1\n// after\nbrook server -l :9999 --tag env:prod --tag dc:dc1","handlingStrategy":"validation","validationCode":"for _, t := range tags {\n\tif strings.Count(t, \":\") != 1 {\n\t\treturn fmt.Errorf(\"tag must be key:value, got %q\", t)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce key:value with exactly one colon","Avoid colons in tag values (use host_port style)","Quote --tag arguments in shell scripts"],"tags":["cli","logging","argument-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}