{"record":{"id":"08c3c0059ddd9b7e","repo":"netbirdio/netbird","slug":"switch-profile-v","errorCode":null,"errorMessage":"switch profile: %v","messagePattern":"switch profile: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":239,"sourceCode":"\n\tif ts := waitResp.GetSessionExpiresAt(); ts.IsValid() && !ts.AsTime().IsZero() {\n\t\tdeadline := ts.AsTime().Local()\n\t\tcmd.Printf(\"Session extended. New expiry: %s\\n\", deadline.Format(\"2006-01-02 15:04:05 MST\"))\n\t} else {\n\t\t// Management reported the peer is not eligible (e.g. login\n\t\t// expiration disabled on the account). Surface that fact\n\t\t// instead of pretending the call succeeded.\n\t\tcmd.Println(\"Session extension call completed, but the management server did not return a new deadline (peer may not be SSO-tracked or login expiration is disabled).\")\n\t}\n\treturn nil\n}\n\nfunc getActiveProfile(ctx context.Context, pm *profilemanager.ProfileManager, profileName string, username string) (*profilemanager.Profile, error) {\n\t// switch profile if provided\n\n\tif profileName != \"\" {\n\t\tif err := switchProfileOnDaemon(ctx, pm, profileName, username); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"switch profile: %v\", err)\n\t\t}\n\t}\n\n\tactiveProf, err := pm.GetActiveProfile()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get active profile: %v\", err)\n\t}\n\n\tif activeProf == nil {\n\t\treturn nil, fmt.Errorf(\"active profile not found, please run 'netbird profile create' first\")\n\t}\n\treturn activeProf, nil\n}\n\nfunc switchProfileOnDaemon(ctx context.Context, pm *profilemanager.ProfileManager, handle string, username string) error {\n\tresolvedID, err := switchProfile(ctx, handle, username)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"switch profile on daemon: %v\", err)","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L221-L257","documentation":"Top-level wrapper for the whole profile-switch stage of getActiveProfile: when --profile-name is passed, switchProfileOnDaemon runs a chain (daemon RPC to resolve the profile, local pm.SwitchProfile to persist the active pointer, daemon Status check, optional Down call) and this error reports that one of those steps failed. The inner message ('switch profile on daemon', 'switch profile', 'unable to get daemon status') identifies which link broke.","triggerScenarios":"Passing --profile-name that does not exist or is ambiguous; daemon not running when the CLI dials it; local profile store not writable when persisting the active profile; daemon connected and the subsequent Down RPC fails.","commonSituations":"Typos in profile names after 'netbird profile list' output changed; running the CLI as a different user than the one who owns the config dir; daemon mid-restart during service upgrade; read-only home directory (NFS root-squash, container).","solutions":["Run 'netbird profile list' and pass the exact profile name or full ID","Ensure the daemon is up: 'netbird service install && netbird service start'","Check write permissions on the CLI config dir (~/.netbird or NB_CONFIG_DIR) if the inner error is the local 'switch profile' step","Read the inner wrapped message and apply the fix for the failing sub-step (errors 224-227)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the target profile exists before switching\npm := profilemanager.NewProfileManager()\nprofiles, err := pm.GetProfiles()\nif err == nil {\n    for _, p := range profiles {\n        if p.Name == profileName {\n            return nil // safe to proceed with getActiveProfile\n        }\n    }\n    return fmt.Errorf(\"profile %q not found; run 'netbird profile list'\", profileName)\n}","typeGuard":null,"tryCatchPattern":"prof, err := getActiveProfile(ctx, pm, profileName, username)\nif err != nil {\n    inner := errors.Unwrap(err)\n    if strings.HasPrefix(inner.Error(), \"switch profile on daemon\") {\n        // daemon-side: check service, exact profile name\n    }\n    return err\n}","preventionTips":["Pin automation to full profile IDs, not names, to survive renames","Run 'netbird profile list' in scripts before switching to assert the profile exists","Keep daemon ownership and config-dir ownership under the same user"],"tags":["profile","daemon","cli","grpc","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}