{"record":{"id":"868aebff75d6e4bb","repo":"slackhq/nebula","slug":"inetworkconnection-getnetwork-s","errorCode":null,"errorMessage":"INetworkConnection.GetNetwork: %s","messagePattern":"INetworkConnection\\.GetNetwork: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"overlay/network_category_windows.go","lineNumber":199,"sourceCode":"\nfunc (c *iNetworkConnection) GetAdapterId() (windows.GUID, error) {\n\tvar g windows.GUID\n\tr1, _, _ := syscall.SyscallN(c.Vtbl.GetAdapterId,\n\t\tuintptr(unsafe.Pointer(c)), uintptr(unsafe.Pointer(&g)),\n\t)\n\tif hr := hresult(r1); hr.failed() {\n\t\treturn windows.GUID{}, fmt.Errorf(\"INetworkConnection.GetAdapterId: %s\", hr)\n\t}\n\treturn g, nil\n}\n\nfunc (c *iNetworkConnection) GetNetwork() (*iNetwork, error) {\n\tvar net *iNetwork\n\tr1, _, _ := syscall.SyscallN(c.Vtbl.GetNetwork,\n\t\tuintptr(unsafe.Pointer(c)), uintptr(unsafe.Pointer(&net)),\n\t)\n\tif hr := hresult(r1); hr.failed() {\n\t\treturn nil, fmt.Errorf(\"INetworkConnection.GetNetwork: %s\", hr)\n\t}\n\treturn net, nil\n}\n\ntype iNetworkVtbl struct {\n\tiDispatchVtbl\n\tGetName                    uintptr\n\tSetName                    uintptr\n\tGetDescription             uintptr\n\tSetDescription             uintptr\n\tGetNetworkId               uintptr\n\tGetDomainType              uintptr\n\tGetNetworkConnections      uintptr\n\tGetTimeCreatedAndConnected uintptr\n\tIsConnectedToInternet      uintptr\n\tIsConnected                uintptr\n\tGetConnectivity            uintptr\n\tGetCategory                uintptr","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/overlay/network_category_windows.go#L181-L217","documentation":"This error wraps a failed HRESULT from INetworkConnection::GetNetwork, which retrieves the INetwork object for a connection during Windows network category detection. A failing HRESULT indicates the COM call into Network List Manager failed (service state, stale pointer, or COM apartment issues).","triggerScenarios":"Calling GetNetwork() on an iNetworkConnection during tun setup's network classification when the NLM COM vtbl call returns a failing HRESULT.","commonSituations":"Network List Service restarting mid-scan; stale connection pointers after rapid adapter changes (common with VPN adapters coming up/down); COM threading violations; stripped or locked-down Windows environments.","solutions":["Ensure Network List Service (netprofm) is running and stable before tunnel startup","Re-enumerate connections and retry with a fresh iNetworkConnection pointer","Keep COM usage on the initializing thread/apartment to avoid RPC_E_WRONG_THREAD style failures","Read the hresult in the message to pinpoint the COM failure and skip category detection non-fatally if classification is optional"],"exampleFix":"// before\nnet, err := conn.GetNetwork()\nif err != nil { return err }\n// after\nnet, err := conn.GetNetwork()\nif err != nil {\n    l.WithError(err).Warn(\"unable to get INetwork for connection; skipping category detection\")\n    return nil\n}","handlingStrategy":"retry","validationCode":"// verify the service is up before the COM chain\nif err := nlmAvailable(); err != nil {\n    return fmt.Errorf(\"skip classification: %w\", err)\n}","typeGuard":"func isGetNetworkError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"INetworkConnection.GetNetwork:\")\n}","tryCatchPattern":"net, err := conn.GetNetwork()\nif err != nil {\n    if isGetNetworkError(err) {\n        // retry once with a fresh connection pointer\n        if c2, rerr := refreshConnection(); rerr == nil {\n            net, err = c2.GetNetwork()\n        }\n    }\n    if err != nil { return nil } // best-effort\n}","preventionTips":["Confirm netprofm stability before starting classification","Refresh COM pointers whenever the network profile changes","Use one thread for the whole GetNetworkConnections→Next→GetNetwork→GetCategory chain","Log hresults for post-mortem diagnosis"],"tags":["windows","com","winapi","network-list-manager"],"backgroundTag":"com-call-failed","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}