{"record":{"id":"d249e62edcd312e3","repo":"go-kratos/kratos","slug":"failed-to-extract-port-v","errorCode":null,"errorMessage":"failed to extract port: %v","messagePattern":"failed to extract port: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/host/host.go","lineNumber":42,"sourceCode":"\n// Port return a real port.\nfunc Port(lis net.Listener) (int, bool) {\n\tif addr, ok := lis.Addr().(*net.TCPAddr); ok {\n\t\treturn addr.Port, true\n\t}\n\treturn 0, false\n}\n\n// Extract returns a private addr and port.\nfunc Extract(hostPort string, lis net.Listener) (string, error) {\n\taddr, port, err := net.SplitHostPort(hostPort)\n\tif err != nil && lis == nil {\n\t\treturn \"\", err\n\t}\n\tif lis != nil {\n\t\tp, ok := Port(lis)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"failed to extract port: %v\", lis.Addr())\n\t\t}\n\t\tport = strconv.Itoa(p)\n\t}\n\tif len(addr) > 0 && (addr != \"0.0.0.0\" && addr != \"[::]\" && addr != \"::\") {\n\t\treturn net.JoinHostPort(addr, port), nil\n\t}\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar (\n\t\tminIndex = 0\n\t\tips      = make([]net.IP, 0, 1)\n\t)\n\tfor _, iface := range ifaces {\n\t\tif iface.Flags&net.FlagUp == 0 {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/internal/host/host.go#L24-L60","documentation":"Error \"failed to extract port: %v\" thrown in go-kratos/kratos.","triggerScenarios":"Thrown at internal/host/host.go:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}