{"record":{"id":"84b7387a26919771","repo":"docker/cli","slug":"invalid-protocol-value-s","errorCode":null,"errorMessage":"invalid protocol value '%s'","messagePattern":"invalid protocol value '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/swarmopts/port.go","lineNumber":64,"sourceCode":"\t\t}\n\n\t\tpConfig := swarm.PortConfig{\n\t\t\tProtocol:    network.TCP,\n\t\t\tPublishMode: swarm.PortConfigPublishModeIngress,\n\t\t}\n\t\tfor _, field := range fields {\n\t\t\t// TODO(thaJeztah): these options should not be case-insensitive.\n\t\t\tkey, val, ok := strings.Cut(strings.ToLower(field), \"=\")\n\t\t\tif !ok || key == \"\" {\n\t\t\t\treturn fmt.Errorf(\"invalid field: %s\", field)\n\t\t\t}\n\t\t\tswitch key {\n\t\t\tcase portOptProtocol:\n\t\t\t\tswitch proto := network.IPProtocol(val); proto {\n\t\t\t\tcase network.TCP, network.UDP, network.SCTP:\n\t\t\t\t\tpConfig.Protocol = proto\n\t\t\t\tdefault:\n\t\t\t\t\treturn fmt.Errorf(\"invalid protocol value '%s'\", val)\n\t\t\t\t}\n\t\t\tcase portOptMode:\n\t\t\t\tswitch swarm.PortConfigPublishMode(val) {\n\t\t\t\tcase swarm.PortConfigPublishModeIngress, swarm.PortConfigPublishModeHost:\n\t\t\t\t\tpConfig.PublishMode = swarm.PortConfigPublishMode(val)\n\t\t\t\tdefault:\n\t\t\t\t\treturn fmt.Errorf(\"invalid publish mode value (%s): must be either '%s' or '%s'\", val, swarm.PortConfigPublishModeIngress, swarm.PortConfigPublishModeHost)\n\t\t\t\t}\n\t\t\tcase portOptTargetPort:\n\t\t\t\ttPort, err := strconv.ParseUint(val, 10, 16)\n\t\t\t\tif err != nil {\n\t\t\t\t\tvar numErr *strconv.NumError\n\t\t\t\t\tif errors.As(err, &numErr) {\n\t\t\t\t\t\terr = numErr.Err\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"invalid target port (%s): value must be an integer: %w\", val, err)\n\t\t\t\t}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/swarmopts/port.go#L46-L82","documentation":"Thrown by PortOpt.Set (port.go:64) when the `protocol` field value is not a recognized IP protocol. The switch over network.IPProtocol(val) only accepts tcp, udp, sctp (case-sensitive to whatever IPProtocol normalizes to); anything else falls to default and is rejected.","triggerScenarios":"Passing `--publish target=80,protocol=http`, `protocol=icmp`, `protocol=TCP6`, or a typo like `protocol=tc`. network.IPProtocol returns a value outside {TCP,UDP,SCTP} so the default case at line 63 fires.","commonSituations":"Assuming arbitrary protocol names are supported, typos, or using uppercase variants the normalizer doesn't accept. Also from copy-paste of an IANA protocol name like 'https'.","solutions":["Use one of: tcp, udp, sctp for the protocol field.","Check spelling and remove extra whitespace.","If you don't need a non-standard protocol, omit the field (defaults to tcp).","Verify network.IPProtocol accepts your value; it is strict."],"exampleFix":"// before\n--publish published=8080,target=80,protocol=http\n// after\n--publish published=8080,target=80,protocol=tcp","handlingStrategy":"validation","validationCode":"// Restrict protocol to the supported set.\nvar okProto = map[string]bool{\"tcp\": true, \"udp\": true, \"sctp\": true}\nif !okProto[strings.ToLower(protocolVal)] {\n    return fmt.Errorf(\"protocol %q must be tcp, udp, or sctp\", protocolVal)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use tcp, udp, or sctp only.","Omit protocol to default to tcp.","Don't confuse application protocols (http) with transport protocols.","Validate against network.IPProtocol in wrappers."],"tags":["docker","swarm","port","validation","networking","protocol","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}