{"record":{"id":"f5ee03ec12538889","repo":"netbirdio/netbird","slug":"get-active-profile-v-f5ee03","errorCode":null,"errorMessage":"get active profile: %v","messagePattern":"get active profile: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/up.go","lineNumber":141,"sourceCode":"\tpm := profilemanager.NewProfileManager()\n\n\tusername, err := user.Current()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get current user: %v\", err)\n\t}\n\n\tvar profileSwitched bool\n\t// switch profile if provided\n\tif profileName != \"\" {\n\t\tif err := switchOrCreateProfile(cmd.Context(), pm, profileName, username.Username); err != nil {\n\t\t\treturn fmt.Errorf(\"switch profile: %v\", err)\n\t\t}\n\t\tprofileSwitched = true\n\t}\n\n\tactiveProf, err := pm.GetActiveProfile()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get active profile: %v\", err)\n\t}\n\n\tif foregroundMode {\n\t\treturn runInForegroundMode(ctx, cmd, activeProf)\n\t}\n\treturn runInDaemonMode(ctx, cmd, pm, activeProf, profileSwitched)\n}\n\n// switchOrCreateProfile switches the active profile to the one identified by\n// handle, creating it first when it does not exist yet. This restores the\n// pre-0.73 behaviour where `netbird up --profile <name>` auto-creates a\n// missing profile instead of failing.\nfunc switchOrCreateProfile(ctx context.Context, pm *profilemanager.ProfileManager, handle, username string) error {\n\tresolvedID, err := switchProfile(ctx, handle, username)\n\tif err != nil {\n\t\tst, ok := gstatus.FromError(err)\n\t\tif !ok || st.Code() != codes.NotFound {\n\t\t\treturn err","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/up.go#L123-L159","documentation":"Thrown by upFunc (client/cmd/up.go:141) when pm.GetActiveProfile() fails to load the active profile from the local profile manager store. The CLI needs the active profile to know which config file to use. It fails when no active profile is set (fresh or migrated store) or when the store cannot be read (permissions, corruption).","triggerScenarios":"Running 'netbird up' on a fresh install before any profile exists; a profile store JSON that is unreadable or hand-corrupted; the store directory owned by root after mixing sudo and non-sudo invocations; a partially completed 0.73-era profile migration.","commonSituations":"First run after install; deleted or moved ~/.config/netbird; running the CLI as a different user than the one who set up profiles.","solutions":["Run 'netbird profiles list' to inspect the store and see whether any profile is marked active","Switch to an existing profile or let up create one: 'netbird up --profile <name>'","Fix ownership of the netbird config directory (chown -R $USER) if sudo/non-sudo mixing corrupted it","As a last resort, back up and remove the profile store so it is recreated cleanly"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if _, err := pm.GetActiveProfile(); err != nil {\n    // fresh store: create/select a profile explicitly instead of relying on default\n    log.Warn(\"no active profile - run netbird up --profile <name> to bootstrap\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bootstrap with 'netbird up --profile <name>' on fresh installs","Run 'netbird profiles list' after migrations to confirm an active profile exists","Keep ~/.config/netbird owned by one user"],"tags":["cli","profiles","filesystem","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}