{"record":{"id":"d1464d51a96f5b0f","repo":"netbirdio/netbird","slug":"management-client-is-not-initialised","errorCode":null,"errorMessage":"management client is not initialised","messagePattern":"management client is not initialised","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/internal/engine_authsession.go","lineNumber":88,"sourceCode":"func (e *Engine) DismissSessionWarning() {\n\tif e.sessionWatcher == nil {\n\t\treturn\n\t}\n\te.sessionWatcher.Dismiss()\n}\n\n// ExtendAuthSession asks the management server to refresh the SSO session\n// expiry deadline using the supplied JWT, then mirrors the new deadline into\n// the daemon's state. The tunnel is untouched; no resync, no reconnect.\n//\n// Returns the new absolute UTC deadline (or zero time when the server\n// reports the peer is not eligible for extension).\nfunc (e *Engine) ExtendAuthSession(ctx context.Context, jwtToken string) (time.Time, error) {\n\tif jwtToken == \"\" {\n\t\treturn time.Time{}, errors.New(\"jwt token is required\")\n\t}\n\tif e.mgmClient == nil {\n\t\treturn time.Time{}, errors.New(\"management client is not initialised\")\n\t}\n\n\tinfo, err := system.GetInfoWithChecks(ctx, e.checks)\n\tif err != nil {\n\t\tlog.Warnf(\"failed to collect system info for session extend: %v\", err)\n\t\tinfo = system.GetInfo(ctx)\n\t}\n\n\tresp, err := e.mgmClient.ExtendAuthSession(info, jwtToken)\n\tif err != nil {\n\t\treturn time.Time{}, fmt.Errorf(\"extend auth session on management: %w\", err)\n\t}\n\n\te.ApplySessionDeadline(resp.GetSessionExpiresAt())\n\n\tif resp.GetSessionExpiresAt().IsValid() {\n\t\treturn resp.GetSessionExpiresAt().AsTime().UTC(), nil\n\t}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/internal/engine_authsession.go#L70-L106","documentation":"Thrown by Engine.ExtendAuthSession (client/internal/engine_authsession.go:88) when the engine's management gRPC client (e.mgmClient) is nil. That client is only created when the engine starts and connects to the NetBird management service, so a nil value means the engine currently has no management connection and cannot forward the SSO session-extension request. The guard fires before any network call or system-info collection.","triggerScenarios":"Calling ExtendAuthSession (daemon RPC / UI 'refresh session' action) before the engine finished connecting to management, after the engine was stopped (netbird down / logout nils the client), or while the daemon is still in the NeedsLogin or Connecting state.","commonSituations":"Desktop UI or CLI issues a session-extend request immediately after daemon startup, before 'up' completes; a retry races the login flow; the session-extension path is invoked on an engine instance that was already torn down during logout or MDM-triggered restart.","solutions":["Only call ExtendAuthSession when the daemon status reports Connected (query Status/SubscribeStatus first).","If hit during startup, wait for the connection to be established and retry the extend call.","If hit on a long-running daemon, the session/engine was torn down: re-authenticate (login + up) to rebuild the management client.","Check daemon logs for a prior management disconnect that nilled the client."],"exampleFix":"// before\nnewDeadline, err := engine.ExtendAuthSession(ctx, jwt)\nif err != nil {\n    // fails with \"management client is not initialised\" during startup\n}\n\n// after: gate on connection state first\nstatus, _ := daemonClient.Status(ctx)\nif status.GetStatus() != daemonpb.StatusEnum_CONNECTED {\n    // wait or prompt the user to connect before extending\n    return fmt.Errorf(\"connect the daemon before extending the session\")\n}\nnewDeadline, err := engine.ExtendAuthSession(ctx, jwt)","handlingStrategy":"validation","validationCode":"// Before calling ExtendAuthSession, confirm the engine actually holds a\n// management connection.\nstatus, err := daemonClient.Status(ctx)\nif err != nil {\n    return err\n}\nif status.GetStatus() != daemonpb.StatusEnum_CONNECTED {\n    return fmt.Errorf(\"daemon not connected (status %s); connect before extending session\", status.GetStatus())\n}","typeGuard":null,"tryCatchPattern":"// In-process Go callers:\nif _, err := engine.ExtendAuthSession(ctx, jwt); err != nil {\n    if strings.Contains(err.Error(), \"management client is not initialised\") {\n        // engine not connected yet: wait for Connected status and retry once\n    }\n    return err\n}","preventionTips":["Gate every session-management RPC on daemon status Connected.","Never cache an Engine reference across login/logout boundaries; re-acquire it after state changes.","In UIs, disable the 'extend session' action while status is not Connected."],"tags":["go","netbird","daemon","management","sso","session"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}