{"record":{"id":"faeabc16242b7c21","repo":"XTLS/Xray-core","slug":"invalid-portmap","errorCode":null,"errorMessage":"invalid portMap: {}","messagePattern":"invalid portMap: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/dokodemo.go","lineNumber":41,"sourceCode":"\tif v.Network != nil {\n\t\tv.AllowedNetwork = v.Network\n\t}\n\tif v.Address != nil {\n\t\tv.RewriteAddress = v.Address\n\t}\n\tif v.Port != 0 {\n\t\tv.RewritePort = v.Port\n\t}\n\tconfig := new(dokodemo.Config)\n\tconfig.AllowedNetworks = v.AllowedNetwork.Build()\n\tif v.RewriteAddress != nil {\n\t\tconfig.RewriteAddress = v.RewriteAddress.Build()\n\t}\n\tconfig.RewritePort = uint32(v.RewritePort)\n\tconfig.PortMap = v.PortMap\n\tfor _, v := range config.PortMap {\n\t\tif _, _, err := net.SplitHostPort(v); err != nil {\n\t\t\treturn nil, errors.New(\"invalid portMap: \", v).Base(err)\n\t\t}\n\t}\n\tconfig.FollowRedirect = v.FollowRedirect\n\tconfig.UserLevel = v.UserLevel\n\treturn config, nil\n}\n","sourceCodeStart":23,"sourceCodeEnd":48,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/dokodemo.go#L23-L48","documentation":"Thrown while building a dokodemo-door inbound config when an entry of 'portMap' cannot be split into host:port by net.SplitHostPort. Each portMap entry must be a \"from:to\" address pair where the port part is parseable; the underlying SplitHostPort error is attached as the base cause. It fires during config Build() before the inbound starts.","triggerScenarios":"A dokodemo inbound with \"portMap\": [\"80\"] (missing colon / port), \":::80\" malformed IPv6, or an entry with only a port and no destination. Any value for which net.SplitHostPort returns an error triggers it.","commonSituations":"Writing portMap entries as bare ports (\"1080\") instead of address pairs; malformed IPv6 literals missing brackets; trailing colons or whitespace.","solutions":["Format every portMap entry as \"sourcePort:destHost:destPort\" or the documented \"host:port\" pair so SplitHostPort succeeds (e.g. \"80:127.0.0.1:8080\").","Wrap IPv6 literals in brackets: \"[::1]:443\".","Inspect the wrapped base error — it is the exact net.SplitHostPort reason (too many colons, missing port, etc.)."],"exampleFix":"// before\n\"portMap\": [\"80\"]\n\n// after\n\"portMap\": [\"80:127.0.0.1:8080\"]","handlingStrategy":"validation","validationCode":"for _, pm := range portMap {\n    if _, _, err := net.SplitHostPort(pm); err != nil {\n        return fmt.Errorf(\"invalid portMap %q: %w\", pm, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Format portMap entries as host:port pairs, bracketing IPv6.","Never put bare ports in portMap.","Test config with `xray run -test` before deploying."],"tags":["go","xray","dokodemo","config","port","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}