{"record":{"id":"2baed3643a6f57e8","repo":"tsenart/vegeta","slug":"invalid-connect-to-q-expected-format-s","errorCode":null,"errorMessage":"invalid -connect-to %q, expected format: %s","messagePattern":"invalid -connect-to %q, expected format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"flags.go","lineNumber":189,"sourceCode":"\t\taddrMappings = append(addrMappings, k+\":\"+strings.Join(v, \",\"))\n\t}\n\n\tsort.Strings(addrMappings)\n\treturn strings.Join(addrMappings, \";\")\n}\n\nfunc (c *connectToFlag) Set(s string) error {\n\tif c.addrMap == nil {\n\t\treturn nil\n\t}\n\n\tif *c.addrMap == nil {\n\t\t*c.addrMap = make(map[string][]string)\n\t}\n\n\tparts := strings.Split(s, \":\")\n\tif len(parts) != 4 {\n\t\treturn fmt.Errorf(\"invalid -connect-to %q, expected format: %s\", s, connectToFormat)\n\t}\n\tsrcAddr := parts[0] + \":\" + parts[1]\n\tdstAddr := parts[2] + \":\" + parts[3]\n\n\t// Parse source address\n\tif _, _, err := net.SplitHostPort(srcAddr); err != nil {\n\t\treturn fmt.Errorf(\"invalid source address expression [%s], expected address:port\", srcAddr)\n\t}\n\n\t// Parse destination address\n\tif _, _, err := net.SplitHostPort(dstAddr); err != nil {\n\t\treturn fmt.Errorf(\"invalid destination address expression [%s], expected address:port\", dstAddr)\n\t}\n\n\t(*c.addrMap)[srcAddr] = append((*c.addrMap)[srcAddr], dstAddr)\n\n\treturn nil\n}","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/flags.go#L171-L207","documentation":"The -connect-to flag maps source host:port to destination host:port and is parsed by splitting on ':'. A valid entry must yield exactly 4 parts (host, port, host, port); anything else cannot be interpreted and is rejected with the expected format shown in connectToFormat.","triggerScenarios":"Calling ConnectTo.Set (or -connect-to) with a value that does not split into exactly 4 ':'-separated parts, e.g. \"example.com:80:localhost:8080:extra\", a bare host, or an IPv6 literal whose extra colons break the count.","commonSituations":"Forgetting one of the two host:port halves; including an IPv6 address (colons inflate the part count); shell mangling of the value; trailing garbage from templating.","solutions":["Use exactly host:port:host:port, e.g. -connect-to=example.com:80:127.0.0.1:8080.","Avoid raw IPv6 literals; use IPv4 or a form compatible with the 4-part split.","Quote the flag value in the shell so colons are preserved.","Validate the value has exactly three colons before invoking vegeta."],"exampleFix":"// before\n-connect-to=example.com:80\n// after\n-connect-to=example.com:80:localhost:8080","handlingStrategy":"validation","validationCode":"func validConnectTo(s string) bool {\n\tparts := strings.Split(s, \":\")\n\tif len(parts) != 4 {\n\t\treturn false\n\t}\n\t_, _, err1 := net.SplitHostPort(parts[0] + \":\" + parts[1])\n\t_, _, err2 := net.SplitHostPort(parts[2] + \":\" + parts[3])\n\treturn err1 == nil && err2 == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly host:port:host:port with three colons.","Avoid raw IPv6 literals (bracket them or use IPv4).","Quote the value in the shell.","Pre-validate with the validConnectTo snippet before launching."],"tags":["cli","flag-parsing","network"],"backgroundTag":"invalid-address-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}