{"record":{"id":"18da8d0dc32da77c","repo":"tsenart/vegeta","slug":"invalid-source-address-expression-s-expected-a","errorCode":null,"errorMessage":"invalid source address expression [%s], expected address:port","messagePattern":"invalid source address expression \\[(.+?)\\], expected address:port","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"flags.go","lineNumber":196,"sourceCode":"func (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}\n","sourceCodeStart":178,"sourceCodeEnd":208,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/flags.go#L178-L208","documentation":"After -connect-to is split into src and dst halves, vegeta validates the source half with net.SplitHostPort. If \"host:port\" is malformed (too many colons, empty host, unbracketed IPv6), Set returns this error naming the offending source expression.","triggerScenarios":"Calling ConnectTo.Set where parts[0]+\":\"+parts[1] fails net.SplitHostPort — e.g. empty host (\":80\") or too many colons (\"a:b:c\").","commonSituations":"IPv6 addresses in the first half without brackets; empty host portion; typos like 'host::port'; programmatic assembly with a missing component.","solutions":["Write the source as a valid host:port pair, e.g. -connect-to='example.com:80:127.0.0.1:8080'.","Wrap IPv6 literals in brackets: '[::1]:8080'.","Ensure the host portion is non-empty.","Test the pair with net.SplitHostPort in your own tooling before passing it to vegeta."],"exampleFix":"// before\n-connect-to='2001:db8::1:80:127.0.0.1:8080'\n// after\n-connect-to='[2001:db8::1]:80:127.0.0.1:8080'","handlingStrategy":"validation","validationCode":"func validSrcAddr(src string) bool {\n\t_, _, err := net.SplitHostPort(src)\n\treturn err == nil\n}\n// apply to the first host:port half of -connect-to","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure non-empty host and exactly one port in the source half.","Bracket IPv6 literals: '[::1]:8080'.","Test the pair with net.SplitHostPort before invoking.","Avoid building the string from unvalidated template fields."],"tags":["cli","network","address-parsing"],"backgroundTag":"invalid-address-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}