{"record":{"id":"ae7e928724df9b01","repo":"netbirdio/netbird","slug":"failed-to-resolve-active-profile-q-w","errorCode":null,"errorMessage":"failed to resolve active profile %q: %w","messagePattern":"failed to resolve active profile %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/android/profile_manager.go","lineNumber":125,"sourceCode":"\t}\n\n\treturn &ProfileArray{items: profiles}, nil\n}\n\n// GetActiveProfile returns the currently active profile name\nfunc (pm *ProfileManager) GetActiveProfile() (*Profile, error) {\n\t// Use ServiceManager to stay consistent with ListProfiles\n\t// ServiceManager uses active_profile.json\n\tactiveState, err := pm.serviceMgr.GetActiveProfileState()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get active profile: %w\", err)\n\t}\n\n\t// ActiveProfileState only stores the ID (and username), not the display\n\t// name. Resolve the ID to the full profile so callers get the real Name.\n\tprof, err := pm.serviceMgr.ResolveProfile(activeState.ID.String(), androidUsername)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to resolve active profile %q: %w\", activeState.ID, err)\n\t}\n\treturn &Profile{\n\t\tID:       prof.ID.String(),\n\t\tName:     prof.Name,\n\t\tEmail:    pm.profileEmail(prof.ID.String()),\n\t\tIsActive: true,\n\t}, nil\n}\n\n// profileEmail returns the account email recorded for a profile. Display-only, so\n// an unresolvable path degrades to \"\" rather than an error.\nfunc (pm *ProfileManager) profileEmail(id string) string {\n\tconfigPath, err := pm.getProfileConfigPath(id)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn readProfileEmail(configPath)\n}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/android/profile_manager.go#L107-L143","documentation":"active_profile.json was read successfully, but ServiceManager.ResolveProfile could not find or load the profile config the stored ID points to. The state is stale: the profile file was deleted, renamed out-of-band, or never existed under profiles/ (or netbird.cfg for the default profile). The offending ID is included in the message.","triggerScenarios":"active_profile.json references an id whose file was removed outside RemoveProfile (file manager, crashed removal leaving the state file behind), a config-dir migration lost the profile files, or the default profile is active but netbird.cfg is absent.","commonSituations":"Partial app-data restore, manual file deletion, interrupted RemoveProfile, config directory moved between app versions.","solutions":["Call ListProfiles to see which profiles actually exist on disk","Re-point the state with SwitchProfile to an existing profile id (or \"default\")","Or delete active_profile.json so the next activation recreates it","If the config files were lost, log in again to recreate the profile"],"exampleFix":"// before\nactive, err := pm.GetActiveProfile() // fails: dangling id in active_profile.json\n\n// after: reset the active state to a profile that exists\nif _, err := pm.GetActiveProfile(); err != nil {\n\t_ = pm.SwitchProfile(\"default\") // or an id confirmed via ListProfiles\n}","handlingStrategy":"fallback","validationCode":"// Before trusting the active id, confirm its config exists\nlist, err := pm.ListProfiles()\nif err == nil && !containsId(list, activeId) {\n\t// dangling state: re-switch instead of calling GetActiveProfile\n}","typeGuard":null,"tryCatchPattern":"if _, err := pm.GetActiveProfile(); err != nil && strings.Contains(err.Error(), \"failed to resolve active profile\") {\n\t_ = pm.SwitchProfile(\"default\") // reset the stale pointer, then retry\n\t_, _ = pm.GetActiveProfile()\n}","preventionTips":["Always remove profiles through RemoveProfile so state and files stay consistent","After manual file cleanup or restores, re-run SwitchProfile to an existing id","Treat a dangling active id as resettable state, not as corruption requiring reinstall"],"tags":["android","go","profile","filesystem","state"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}