{"record":{"id":"e523740406575fce","repo":"netbirdio/netbird","slug":"profile-not-found","errorCode":null,"errorMessage":"profile not found","messagePattern":"profile not found","errorType":"exception","errorClass":"ErrProfileNotFound","httpStatus":null,"severity":"error","filePath":"client/internal/profilemanager/error.go","lineNumber":6,"sourceCode":"package profilemanager\n\nimport \"errors\"\n\nvar (\n\tErrProfileNotFound      = errors.New(\"profile not found\")\n\tErrProfileAlreadyExists = errors.New(\"profile already exists\")\n\tErrNoActiveProfile      = errors.New(\"no active profile set\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":10,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/internal/profilemanager/error.go#L1-L10","documentation":"Sentinel error ErrProfileNotFound (client/internal/profilemanager/error.go:6) returned by the profile manager store when an operation references a profile ID that does not exist in the persisted profile store. Profiles are keyed by ID and hold per-account daemon configuration, so any Get/Update/Delete/Switch on an unknown ID fails fast with this sentinel instead of silently creating state.","triggerScenarios":"profilemanager.UpdateProfile/DeleteProfile/SwitchToProfile called with an ID not present in the store; a UI holding a cached profile ID after that profile was deleted from another process (CLI); the store file was reset or restored from a backup without that profile.","commonSituations":"CLI and desktop UI used concurrently: UI caches an ID, user removes the profile via CLI, next UI write fails. Store migration or a wiped state directory leaves stale references. Tests that hand-construct profile IDs instead of using ones returned by CreateProfile.","solutions":["List all profiles (the profile manager enumerate API) and use IDs it returns instead of hard-coded or cached IDs.","If the profile should exist, re-create it with the intended settings.","Clear the stale reference (e.g. reset the active-profile pointer) so subsequent operations use a valid ID."],"exampleFix":"// before\nerr := store.UpdateProfile(staleProfileID, update)\n\n// after\nif _, err := store.GetProfile(ctx, staleProfileID); profilemanager.IsProfileNotFound(err) {\n    // profile vanished; recreate instead of updating\n    _, err = store.CreateProfile(ctx, desiredSettings)\n}","handlingStrategy":"try-catch","validationCode":"// Verify the profile exists before mutating it.\nprofiles, err := store.GetAllProfiles(ctx)\nif err != nil {\n    return err\n}\nif !containsProfile(profiles, wantedID) {\n    return fmt.Errorf(\"profile %q missing; recreate it\", wantedID)\n}","typeGuard":"func IsProfileNotFound(err error) bool {\n    return errors.Is(err, profilemanager.ErrProfileNotFound)\n}","tryCatchPattern":"err := store.UpdateProfile(ctx, id, upd)\nif profilemanager.IsProfileNotFound(err) {\n    // recreate the profile or refresh the UI's profile list\n}\nif err != nil {\n    return fmt.Errorf(\"update profile: %w\", err)\n}","preventionTips":["Always use IDs returned by the profile manager, never cached or hand-written ones.","After any delete/switch operation, refresh the enumerated profile list in UI state.","Match sentinels with errors.Is, not string comparison, so wrapping keeps working."],"tags":["go","netbird","profile","storage","state"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}