{"record":{"id":"dbc3cf6c8842ad0e","repo":"slimtoolkit/slim","slug":"invalid-publish-port-s","errorCode":null,"errorMessage":"invalid publish-port: %s","messagePattern":"invalid publish-port: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/clifvparser.go","lineNumber":123,"sourceCode":"\t\t\t\tportKey = parts[1]\n\t\t\t} else {\n\t\t\t\tportKey = fmt.Sprintf(\"%s/tcp\", parts[1])\n\t\t\t}\n\t\tcase 3:\n\t\t\thostIP = parts[0]\n\t\t\tif len(parts[1]) > 0 {\n\t\t\t\thostPort = parts[1]\n\t\t\t} else {\n\t\t\t\thostPort = parts[2]\n\t\t\t}\n\n\t\t\tif strings.Contains(parts[2], \"/\") {\n\t\t\t\tportKey = parts[2]\n\t\t\t} else {\n\t\t\t\tportKey = fmt.Sprintf(\"%s/tcp\", parts[2])\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"invalid publish-port: %s\", raw)\n\t\t}\n\n\t\tportBindings[docker.Port(portKey)] = []docker.PortBinding{{\n\t\t\tHostIP:   hostIP,\n\t\t\tHostPort: hostPort,\n\t\t}}\n\t}\n\n\treturn portBindings, nil\n}\n\nfunc IsOneSpace(value string) bool {\n\tif len(value) > 0 && utf8.RuneCountInString(value) == 1 {\n\t\tr, _ := utf8.DecodeRuneInString(value)\n\t\tif r != utf8.RuneError && unicode.IsSpace(r) {\n\t\t\treturn true\n\t\t}\n\t}","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/clifvparser.go#L105-L141","documentation":"ParsePortBindings returns 'invalid publish-port: %s' when a publish-port value does not match any accepted hostIP:hostPort:containerPort shape. The parser switches on the number of ':'-separated parts and the default branch rejects values with an unexpected structure. Valid forms are like '80', '8080:80', '127.0.0.1:8080:80' (with optional protocol suffix).","triggerScenarios":"Calling ParsePortBindings (from CommandFlagValues or inline parsers) with values like 'tcp://80', '80:80:80:80', empty segments, or other malformed publish specs.","commonSituations":"Typos with extra colons; IPv6 addresses with unbracketed colons confusing the splitter; users pasting full docker run -p syntax variants the slim parser does not support.","solutions":["Use one of the supported forms: 'containerPort', 'host:container', or 'ip:host:container'.","Wrap IPv6 host addresses in brackets, e.g. '[::1]:8080:80', so colon splitting stays correct.","Remove duplicate or extra segments (max three colon-separated parts).","Echo the offending raw value against docker run -p documentation to spot the deviation."],"exampleFix":"// before\npublish := []string{\"8080:80:80:extra\"}\n// after\npublish := []string{\"8080:80\"}","handlingStrategy":"validation","validationCode":"parts := strings.Split(raw, \":\")\nswitch len(parts) {\ncase 1, 2, 3:\n    for _, p := range parts {\n        if strings.TrimSpace(p) == \"\" {\n            return fmt.Errorf(\"empty segment in publish-port %q\", raw)\n        }\n    }\ndefault:\n    return fmt.Errorf(\"publish-port %q: expected at most 3 colon-separated parts\", raw)\n}","typeGuard":null,"tryCatchPattern":"bindings, err := command.ParsePortBindings(values)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid publish-port\") {\n        return fmt.Errorf(\"supported forms: port | host:port | ip:host:port: %w\", err)\n    }\n    return err\n}","preventionTips":["Stick to docker run -p accepted shapes: port, host:port, ip:host:port.","Bracket IPv6 host addresses so ':' splitting works.","Avoid extra protocol segments unsupported by this parser.","Test publish parsing with representative flag values in CI."],"tags":["docker","ports","publish","cli-parsing"],"backgroundTag":"invalid-port-syntax","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}