{"record":{"id":"74d33e832e91b225","repo":"netbirdio/netbird","slug":"get-active-profile-file-path-v","errorCode":null,"errorMessage":"get active profile file path: %v","messagePattern":"get active profile file path: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":327,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"switch profile failed: %w\", err)\n\t}\n\n\treturn profilemanager.ID(resp.Id), nil\n}\n\nfunc doForegroundLogin(ctx context.Context, cmd *cobra.Command, setupKey string, activeProf *profilemanager.Profile) error {\n\n\terr := handleRebrand(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// update host's static platform and system information\n\tsystem.UpdateStaticInfoAsync()\n\n\tconfigFilePath, err := activeProf.FilePath()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get active profile file path: %v\", err)\n\n\t}\n\n\tconfig, err := profilemanager.ReadConfig(configFilePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read config file %s: %v\", configFilePath, err)\n\t}\n\n\t// Mirror runInForegroundMode: recover residual state (DNS, firewall,\n\t// ssh config, legacy routing) from a previous unclean shutdown and\n\t// enable advanced routing before dialing management.\n\tif err := server.RestoreResidualState(ctx, profilemanager.NewServiceManager(configFilePath).GetStatePath()); err != nil {\n\t\tlog.Warnf(\"failed to restore residual state: %v\", err)\n\t}\n\tnbnet.Init()\n\n\terr = foregroundLogin(ctx, cmd, config, setupKey, activeProf.ID)\n\tif err != nil {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L309-L345","documentation":"activeProf.FilePath() could not produce the config file path for the active profile. Per client/internal/profilemanager/profilemanager.go:36 this fails when the Profile has neither ID nor Name (incomplete loader entry), the ID is not a valid filename stem, user.Current() fails (no resolvable OS user), or the per-user config directory cannot be determined. It is a structural/environment error, not a network one.","triggerScenarios":"Hand-edited or corrupted profile JSON missing id/name fields; profile ID containing characters rejected by IsValidProfileFilenameStem; running in a minimal container/CI without a proper user database (user.Current fails); NB_CONFIG_DIR/XDG environment pointing somewhere unresolvable.","commonSituations":"Profile store edited by hand or by external tooling; Running the CLI as a UID with no passwd entry (some container runtimes); Config dir moved without updating environment variables","solutions":["Inspect the profiles file in the config dir and recreate the broken profile ('netbird profile create'), or delete the malformed entry","Run the CLI as a real user with a valid HOME and passwd entry","Verify NB_CONFIG_DIR / XDG_CONFIG_HOME resolve to an existing directory","Avoid hand-editing profile JSON; use the profile subcommands"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject structurally incomplete profiles before deriving a file path\nif prof.ID == \"\" && prof.Name == \"\" {\n    return fmt.Errorf(\"profile has empty ID and name; recreate it\")\n}\npath, err := prof.FilePath()\nif err != nil {\n    return err\n}","typeGuard":"// hasResolvablePath narrows profiles that can produce a config path\nfunc hasResolvablePath(p profilemanager.Profile) bool {\n    return p.ID != \"\" || p.Name != \"\"\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit profile JSON; use the profile subcommands","Run the CLI under a real user account (valid passwd entry, HOME set), especially in containers","Validate profile exports before importing them into a new store"],"tags":["profile","filesystem","environment","cli","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}