{"record":{"id":"2ea2de45ac24fb14","repo":"caddyserver/caddy","slug":"invalid-end-port-v","errorCode":null,"errorMessage":"invalid end port: %v","messagePattern":"invalid end port: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"listeners.go","lineNumber":359,"sourceCode":"\t\t\tHost:    host,\n\t\t}, nil\n\t}\n\tvar start, end uint64\n\tif port == \"\" {\n\t\tstart = uint64(defaultPort)\n\t\tend = uint64(defaultPort)\n\t} else {\n\t\tbefore, after, found := strings.Cut(port, \"-\")\n\t\tif !found {\n\t\t\tafter = before\n\t\t}\n\t\tstart, err = strconv.ParseUint(before, 10, 16)\n\t\tif err != nil {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"invalid start port: %v\", err)\n\t\t}\n\t\tend, err = strconv.ParseUint(after, 10, 16)\n\t\tif err != nil {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"invalid end port: %v\", err)\n\t\t}\n\t\tif end < start {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"end port must not be less than start port\")\n\t\t}\n\t\tif (end - start) > maxPortSpan {\n\t\t\treturn NetworkAddress{}, fmt.Errorf(\"port range exceeds %d ports\", maxPortSpan)\n\t\t}\n\t}\n\treturn NetworkAddress{\n\t\tNetwork:   network,\n\t\tHost:      host,\n\t\tStartPort: uint(start),\n\t\tEndPort:   uint(end),\n\t}, nil\n}\n\n// SplitNetworkAddress splits a into its network, host, and port components.\n// Note that port may be a port range (:X-Y), or omitted for unix sockets.","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/listeners.go#L341-L377","documentation":"Same parsing step as the start-port error, but for the end port of a range: after strings.Cut on '-', the 'after' part must parse as uint16. A single port '8080' sets after = before, so the same constraints apply; failures here are reported with this message.","triggerScenarios":"Ranges like ':8080-https', ':80-99999', ':80-90a0', ':80-' (empty end), or ':80- 90' with whitespace. Any non-numeric or >65535 end port.","commonSituations":"Typing a range with a service name at the end, trailing whitespace from templating, or hyphens inside IPv6 literals confusing the split.","solutions":["Make the end port a plain integer within 0-65535: ':8080-8090'.","Remove whitespace and stray characters around the hyphen.","For IPv6, wrap the host in brackets: '[::1]:8080-8090' so the port split is unambiguous."],"exampleFix":"// before\ncaddy.ParseNetworkAddress(\":8080-809O\") // letter O\n// after\ncaddy.ParseNetworkAddress(\":8080-8090\")","handlingStrategy":"validation","validationCode":"func validPortRange(s string) bool {\n    before, after, found := strings.Cut(s, \"-\")\n    if !found { after = before }\n    for _, p := range []string{before, after} {\n        n, err := strconv.ParseUint(p, 10, 16)\n        if err != nil { return false }\n        _ = n\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For IPv6 hosts, always bracket: [::1]:80-90.","Trim whitespace around port strings before embedding."],"tags":["port","parsing","validation","port-range"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}