{"id":"cad287813df756b0","repo":"docker/cli","slug":"invalid-publish-mode-value-s-must-be-either","errorCode":null,"errorMessage":"invalid publish mode value (%s): must be either '%s' or '%s'","messagePattern":"invalid publish mode value \\((.+?)\\): must be either '(.+?)' or '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/swarmopts/port.go","lineNumber":71,"sourceCode":"\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\n\t\t\t\tpConfig.TargetPort = uint32(tPort)\n\t\t\tcase portOptPublishedPort:\n\t\t\t\tpPort, 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","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/swarmopts/port.go#L53-L89","documentation":"Error \"invalid publish mode value (%s): must be either '%s' or '%s'\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/swarmopts/port.go:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}