{"record":{"id":"d278181822d2bd79","repo":"netbirdio/netbird","slug":"get-active-profile-v","errorCode":null,"errorMessage":"get active profile: %v","messagePattern":"get active profile: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/debug.go","lineNumber":115,"sourceCode":"}\n\n// debugConfigDump implements `netbird debug config`. It resolves the\n// active profile, queries the daemon for the effective configuration\n// via GetConfig, and prints the resulting GetConfigResponse as JSON\n// (via protojson with EmitUnpopulated=true so the output is stable\n// across runs and includes zero-valued fields).\n//\n// Useful for verifying MDM enforcement end-to-end: the response's\n// mDMManagedFields array is the single source of truth for \"which\n// fields is the daemon currently enforcing from the MDM source\", and\n// every config field side-by-side with that list confirms the merge\n// result. Secrets in the response (e.g. PreSharedKey) are already\n// redacted by the daemon-side handler.\nfunc debugConfigDump(cmd *cobra.Command, _ []string) error {\n\tpm := profilemanager.NewProfileManager()\n\tactiveProf, err := pm.GetActiveProfile()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get active profile: %v\", err)\n\t}\n\tcurrUser, err := user.Current()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get current user: %v\", err)\n\t}\n\n\tconn, err := getClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tlog.Errorf(errCloseConnection, err)\n\t\t}\n\t}()\n\n\tclient := proto.NewDaemonServiceClient(conn)\n\tresp, err := client.GetConfig(cmd.Context(), &proto.GetConfigRequest{","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/debug.go#L97-L133","documentation":"debugConfigDump starts by reading the active profile from the local profile manager (profilemanager.NewProfileManager().GetActiveProfile()) and wraps its failure here. The profile store holds the per-account config files the CLI/daemon share; GetActiveProfile fails when no profile has ever been created (the machine is not logged in / netbird up never ran) or when the store files cannot be read or parsed.","triggerScenarios":"Running netbird debug config-dump on a machine before the first netbird up/login; the active-profile pointer file is corrupted or empty after a partial write; config directory permissions deny read; NB_CONFIG_DIR/custom env pointing at a non-store directory.","commonSituations":"CI or a fresh VM where the CLI was installed but never connected; a second user account on a shared machine without its own profile; moving/deleting the config dir (~/.config/netbird) while the daemon runs; HOME unset so the store resolves to an unexpected path.","solutions":["Confirm the machine is logged in: netbird status should show a connected peer; if not, run netbird up first and retry the dump","Check the config directory exists and is readable (default ~/.config/netbird, or NB_CONFIG_DIR if set); fix ownership if it was created by root/sudo previously","If the store is corrupted, the direct fix is to re-run netbird login (recreating the profile) — the dump cannot work without a valid active profile","Ensure you run the dump as the same OS user that owns the profile (no interleaved sudo)"],"exampleFix":"# before: dumping before the machine ever connected\nnetbird debug config-dump\n# -> get active profile: ...\n\n# after: connect once, then dump\nnetbird up && netbird debug config-dump","handlingStrategy":"validation","validationCode":"// Ensure a profile exists before dumping:\npm := profilemanager.NewProfileManager()\nprofiles, _ := pm.GetProfiles()\nif len(profiles) == 0 {\n    return fmt.Errorf(\"no profile found; run 'netbird up' first\")\n}\nif _, err := pm.GetActiveProfile(); err != nil {\n    return fmt.Errorf(\"get active profile: %v\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run netbird up once before any debug config-dump usage","Keep the config directory owned by one user; avoid mixing sudo and non-sudo CLI invocations","If HOME is custom in scripts, set NB_CONFIG_DIR explicitly so the store path is deterministic"],"tags":["cli","profile","config","debug","login"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}