netbirdio/netbird · error

failed to check login requirement: %v

Error message

failed to check login requirement: %v

What it means

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.

Source

Thrown at client/android/login.go:162

		if err != nil {
			resultListener.OnError(err)
		} else {
			resultListener.OnSuccess()
		}
	}()
}

func (a *Auth) login(urlOpener URLOpener, isAndroidTV bool) error {
	authClient, err := auth.NewAuth(a.ctx, a.config.PrivateKey, a.config.ManagementURL, a.config)
	if err != nil {
		return fmt.Errorf("failed to create auth client: %v", err)
	}
	defer authClient.Close()

	// check if we need to generate JWT token
	needsLogin, err := authClient.IsLoginRequired(a.ctx)
	if err != nil {
		return fmt.Errorf("failed to check login requirement: %v", err)
	}

	jwtToken := ""
	email := ""
	if needsLogin {
		tokenInfo, err := a.foregroundGetTokenInfo(authClient, urlOpener, isAndroidTV)
		if err != nil {
			return fmt.Errorf("interactive sso login failed: %v", err)
		}
		jwtToken = tokenInfo.GetTokenToUse()
		email = tokenInfo.Email
	}

	err, _ = authClient.Login(a.ctx, "", jwtToken)
	if err != nil {
		return fmt.Errorf("login failed: %v", err)
	}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Retry the login when connectivity is stable.
  2. Keep the app in the foreground during login so Android does not cancel the context.
  3. Confirm management health if the error is immediate and repeatable.
Defensive patterns

Strategy: try-catch

Type guard

func isLoginRequirementCheckFailure(err error) bool {
    return err != nil && strings.HasPrefix(err.Error(), "failed to check login requirement:")
}

Try / catch

err := a.login(urlOpener, isAndroidTV)
if err != nil && isLoginRequirementCheckFailure(err) {
    // RPC to management failed early: retry once connectivity stabilizes;
    // do not launch the browser flow from here
}

Prevention

When it happens

Trigger: 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.

Common situations: Mobile networks dropping mid-login; management redeployments; device going to sleep during the flow.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/f4e0f7accdec8b2d. Report an issue: GitHub.