{"record":{"id":"f4e0f7accdec8b2d","repo":"netbirdio/netbird","slug":"failed-to-check-login-requirement-v","errorCode":null,"errorMessage":"failed to check login requirement: %v","messagePattern":"failed to check login requirement: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/android/login.go","lineNumber":162,"sourceCode":"\t\tif err != nil {\n\t\t\tresultListener.OnError(err)\n\t\t} else {\n\t\t\tresultListener.OnSuccess()\n\t\t}\n\t}()\n}\n\nfunc (a *Auth) login(urlOpener URLOpener, isAndroidTV bool) error {\n\tauthClient, err := auth.NewAuth(a.ctx, a.config.PrivateKey, a.config.ManagementURL, a.config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create auth client: %v\", err)\n\t}\n\tdefer authClient.Close()\n\n\t// check if we need to generate JWT token\n\tneedsLogin, err := authClient.IsLoginRequired(a.ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check login requirement: %v\", err)\n\t}\n\n\tjwtToken := \"\"\n\temail := \"\"\n\tif needsLogin {\n\t\ttokenInfo, err := a.foregroundGetTokenInfo(authClient, urlOpener, isAndroidTV)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"interactive sso login failed: %v\", err)\n\t\t}\n\t\tjwtToken = tokenInfo.GetTokenToUse()\n\t\temail = tokenInfo.Email\n\t}\n\n\terr, _ = authClient.Login(a.ctx, \"\", jwtToken)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"login failed: %v\", err)\n\t}\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/android/login.go#L144-L180","documentation":"Early step of Android interactive login: authClient.IsLoginRequired(ctx) asks management whether an interactive login (JWT) is needed before continuing. Any RPC failure is wrapped as this error with %v, and the login goroutine reports it through the result listener.","triggerScenarios":"Management RPC fails between dial and this call (network flap, server restart); server-side error answering the request; context canceled because the app was backgrounded.","commonSituations":"Mobile networks dropping mid-login; management redeployments; device going to sleep during the flow.","solutions":["Retry the login when connectivity is stable.","Keep the app in the foreground during login so Android does not cancel the context.","Confirm management health if the error is immediate and repeatable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isLoginRequirementCheckFailure(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"failed to check login requirement:\")\n}","tryCatchPattern":"err := a.login(urlOpener, isAndroidTV)\nif err != nil && isLoginRequirementCheckFailure(err) {\n    // RPC to management failed early: retry once connectivity stabilizes;\n    // do not launch the browser flow from here\n}","preventionTips":["Keep the app foregrounded during login so the context is not canceled by Android.","Retry the flow on transient connectivity loss before reporting failure.","Monitor management availability if these errors cluster."],"tags":["android","auth","grpc","network","login"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}