{"record":{"id":"1895acbfade3f327","repo":"netbirdio/netbird","slug":"profile-q-not-found","errorCode":null,"errorMessage":"profile %q not found","messagePattern":"profile %q not found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/profile.go","lineNumber":325,"sourceCode":"// wrapAmbiguityError turns the daemon's gRPC InvalidArgument errors\n// (which carry the resolver's message verbatim) into CLI-friendly text\n// that points the user at --show-id.\nfunc wrapAmbiguityError(err error, handle string) error {\n\tif err == nil {\n\t\treturn nil\n\t}\n\tst, ok := gstatus.FromError(err)\n\tif !ok {\n\t\treturn err\n\t}\n\tswitch st.Code() {\n\tcase codes.InvalidArgument:\n\t\tmsg := st.Message()\n\t\tif strings.Contains(msg, \"ambiguous\") {\n\t\t\treturn errors.New(msg + \"\\nRun `netbird profile list --show-id` to see IDs, then select by ID prefix:\\n  netbird profile select|remove <id-prefix>\")\n\t\t}\n\tcase codes.NotFound:\n\t\treturn fmt.Errorf(\"profile %q not found\", handle)\n\t}\n\treturn err\n}\n\n// addProfileOnDaemon issues the AddProfile RPC on an existing daemon client\n// and returns the new profile's ID. It is the single entry point for profile\n// creation, shared by `netbird profile add` and the `netbird up --profile\n// <name>` auto-create path.\nfunc addProfileOnDaemon(ctx context.Context, client proto.DaemonServiceClient, profileName, username string) (profilemanager.ID, error) {\n\tresp, err := client.AddProfile(ctx, &proto.AddProfileRequest{\n\t\tProfileName: profileName,\n\t\tUsername:    username,\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"add profile failed: %w\", err)\n\t}\n\n\treturn profilemanager.ID(resp.Id), nil","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/profile.go#L307-L343","documentation":"wrapAmbiguityError (client/cmd/profile.go:315-327) translates a codes.NotFound gRPC error from SwitchProfile/RemoveProfile/RenameProfile into 'profile %q not found'. The daemon resolves the handle (profile name or short-ID prefix) among the current user's profiles; a handle matching nothing yields NotFound. A sibling case, InvalidArgument containing 'ambiguous', produces the --show-id guidance instead.","triggerScenarios":"Passing a name or ID prefix that matches no profile for this OS user; profile was deleted in another terminal; typo in the handle; wrong user context (username scopes the lookup); handle is a prefix too short to match after profiles changed.","commonSituations":"Deleting by name when the profile was created under a different name; using a truncated ID that no longer matches; multiple users on one machine each with their own profiles; stale docs/scripts referencing old profile names.","solutions":["List what exists for this user: `netbird profile list --show-id`, then use the printed ID or exact name","Verify you are running as the same OS user that created the profile (the lookup is username-scoped)","For ambiguous-name errors, switch to the unique ID prefix shown by --show-id","Update scripts to reference IDs rather than display names"],"exampleFix":"# before\nnetbird profile select myprofile   # -> profile \"myprofile\" not found\n# after\nnetbird profile list --show-id\nnetbird profile select ab12        # unique short-ID prefix from the list","handlingStrategy":"validation","validationCode":"// Validate the handle against the daemon's own view before mutating\n// CLI equivalent:\n//   netbird profile list --show-id\n// then pass the exact name or a unique short-ID prefix printed there.","typeGuard":"func isKnownProfile(handle string, listed []ProfileView) bool {\n    for _, p := range listed {\n        if p.Name == handle || strings.HasPrefix(p.ShortID, handle) {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"err := daemonClient.SwitchProfile(ctx, req) // or RemoveProfile/RenameProfile\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return fmt.Errorf(\"profile %q not found; run `netbird profile list --show-id`\", handle)\n    }\n    return err\n}","preventionTips":["Reference profiles by short ID from `--show-id` in scripts — names can repeat","Run profile commands as the OS user that owns the profiles","Re-list profiles after deletions before reusing handles"],"tags":["profiles","not-found","grpc-status","cli"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}