{"record":{"id":"90ecfc7b183eb83a","repo":"netbirdio/netbird","slug":"failed-to-create-auth-client-v","errorCode":null,"errorMessage":"failed to create auth client: %v","messagePattern":"failed to create auth client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/android/login.go","lineNumber":94,"sourceCode":"\n// SaveConfigIfSSOSupported test the connectivity with the management server by retrieving the server device flow info.\n// If it returns a flow info than save the configuration and return true. If it gets a codes.NotFound, it means that SSO\n// is not supported and returns false without saving the configuration. For other errors return false.\nfunc (a *Auth) SaveConfigIfSSOSupported(listener SSOListener) {\n\tgo func() {\n\t\tsso, err := a.saveConfigIfSSOSupported()\n\t\tif err != nil {\n\t\t\tlistener.OnError(err)\n\t\t} else {\n\t\t\tlistener.OnSuccess(sso)\n\t\t}\n\t}()\n}\n\nfunc (a *Auth) saveConfigIfSSOSupported() (bool, error) {\n\tauthClient, err := auth.NewAuth(a.ctx, a.config.PrivateKey, a.config.ManagementURL, a.config)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to create auth client: %v\", err)\n\t}\n\tdefer authClient.Close()\n\n\tsupportsSSO, err := authClient.IsSSOSupported(a.ctx)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to check SSO support: %v\", err)\n\t}\n\n\tif !supportsSSO {\n\t\treturn false, nil\n\t}\n\n\terr = profilemanager.WriteOutConfig(a.cfgPath, a.config)\n\treturn true, err\n}\n\n// LoginWithSetupKeyAndSaveConfig test the connectivity with the management server with the setup key.\nfunc (a *Auth) LoginWithSetupKeyAndSaveConfig(resultListener ErrListener, setupKey string, deviceName string) {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/android/login.go#L76-L112","documentation":"In the Android login flow, saveConfigIfSSOSupported builds the management auth client with auth.NewAuth(ctx, privateKey, managementURL, ...). Failure while creating the gRPC client or preparing the key pair is wrapped as this error. Note the wrap uses %v, so the original cause is flattened into the message and cannot be matched with errors.Is.","triggerScenarios":"Management URL unreachable or invalid at dial time; TLS handshake failure against management (untrusted CA, wrong host); private key unreadable or corrupt.","commonSituations":"Typo in the management host; self-hosted management with a certificate the device does not trust; first run on a device with no network.","solutions":["Verify the management URL is reachable from the device (scheme, host, port).","Check that the management TLS certificate chains to a CA the device trusts.","Read the message text after the colon for the cause; if maintaining this code, switch %v to %w so callers can inspect the cause."],"exampleFix":"// before (error cause lost)\nreturn false, fmt.Errorf(\"failed to create auth client: %v\", err)\n\n// after (cause preserved)\nreturn false, fmt.Errorf(\"create auth client: %w\", err)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isAuthClientCreateFailure(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"failed to create auth client:\")\n}","tryCatchPattern":"sso, err := a.saveConfigIfSSOSupported()\nif err != nil {\n    if isAuthClientCreateFailure(err) {\n        // management URL / TLS / key problem: check connectivity and cert\n        // trust before retrying; cause is string-formatted (%v), not wrapped\n    }\n    listener.OnError(err)\n}","preventionTips":["Validate the management URL (scheme, host, port) before starting the login flow.","Ensure the device trusts the management CA; test with curl from the same device class.","If you maintain this code, wrap with %w so callers can use errors.Is on the cause."],"tags":["android","auth","grpc","management","connection"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}