{"action":"created","issue":{"url":"https://api.github.com/repos/heroiclabs/nakama/issues/268","repository_url":"https://api.github.com/repos/heroiclabs/nakama","labels_url":"https://api.github.com/repos/heroiclabs/nakama/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/heroiclabs/nakama/issues/268/comments","events_url":"https://api.github.com/repos/heroiclabs/nakama/issues/268/events","html_url":"https://github.com/heroiclabs/nakama/issues/268","id":383798424,"node_id":"MDU6SXNzdWUzODM3OTg0MjQ=","number":268,"title":"Guard against empty string in usernames array for the Add Friend","user":{"login":"hdjay0129","id":17492225,"node_id":"MDQ6VXNlcjE3NDkyMjI1","avatar_url":"https://avatars2.githubusercontent.com/u/17492225?v=4","gravatar_id":"","url":"https://api.github.com/users/hdjay0129","html_url":"https://github.com/hdjay0129","followers_url":"https://api.github.com/users/hdjay0129/followers","following_url":"https://api.github.com/users/hdjay0129/following{/other_user}","gists_url":"https://api.github.com/users/hdjay0129/gists{/gist_id}","starred_url":"https://api.github.com/users/hdjay0129/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdjay0129/subscriptions","organizations_url":"https://api.github.com/users/hdjay0129/orgs","repos_url":"https://api.github.com/users/hdjay0129/repos","events_url":"https://api.github.com/users/hdjay0129/events{/privacy}","received_events_url":"https://api.github.com/users/hdjay0129/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-23T11:56:15Z","updated_at":"2018-11-23T14:03:05Z","closed_at":null,"author_association":"NONE","body":"## Description\r\nUser A sends AddFriend Request to User B using user B's id in the ids array and an empty string in usernames array.\r\nTwo extra records are inserted into the user_edge table corresponding to no user because of the empty string object in the usernames.\r\n\r\n## Steps to Reproduce\r\n1. Try the below code to add user with userId as friend.\r\n` \r\nprivate async void AddUserAsFriend(string userId)\r\n    {\r\n        Debug.LogFormat(\"[{0}] Sending Friend Request To userId : {1}\", \"AddUserAsFriend\", userId);\r\n        try\r\n        {\r\n            var ids = new[] { userId };\r\n            var usernames = new[] { \"\" };\r\n            await _Client.AddFriendsAsync(_Session, ids, usernames);\r\n\r\n            if (OnAddFriendSuccess != null)\r\n            {\r\n                OnAddFriendSuccess(true);\r\n            }\r\n\r\n        }\r\n        catch (Exception err)\r\n        {\r\n            if (OnAddFriendFailure != null)\r\n            {\r\n                OnAddFriendFailure(err);\r\n            }\r\n        }\r\n    }\r\n`\r\n\r\n## Result\r\nIn the user_edge table two extra entries are recorded due to an empty string in usernames.\r\n`\r\n {\r\n    \"destination_id\": \"26c0c87b-61d1-4bb5-b5cd-b81bdeb75efd\",\r\n    \"position\": 1542920887178669800,\r\n    \"source_id\": \"00000000-0000-0000-0000-000000000000\",\r\n    \"state\": 2,\r\n    \"update_time\": null\r\n}, {\r\n    \"destination_id\": \"00000000-0000-0000-0000-000000000000\",\r\n    \"position\": 1542920887178669800,\r\n    \"source_id\": \"26c0c87b-61d1-4bb5-b5cd-b81bdeb75efd\",\r\n    \"state\": 1,\r\n    \"update_time\": null\r\n}\r\n`\r\n\r\n## Environment\r\nUnity Version - 2018.2.8f1\r\nNakama Version - 2.2.1\r\nCockroach Version - 2.0.5\r\n"},"comment":{"url":"https://api.github.com/repos/heroiclabs/nakama/issues/comments/441248692","html_url":"https://github.com/heroiclabs/nakama/issues/268#issuecomment-441248692","issue_url":"https://api.github.com/repos/heroiclabs/nakama/issues/268","id":441248692,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTI0ODY5Mg==","user":{"login":"hdjay0129","id":17492225,"node_id":"MDQ6VXNlcjE3NDkyMjI1","avatar_url":"https://avatars2.githubusercontent.com/u/17492225?v=4","gravatar_id":"","url":"https://api.github.com/users/hdjay0129","html_url":"https://github.com/hdjay0129","followers_url":"https://api.github.com/users/hdjay0129/followers","following_url":"https://api.github.com/users/hdjay0129/following{/other_user}","gists_url":"https://api.github.com/users/hdjay0129/gists{/gist_id}","starred_url":"https://api.github.com/users/hdjay0129/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdjay0129/subscriptions","organizations_url":"https://api.github.com/users/hdjay0129/orgs","repos_url":"https://api.github.com/users/hdjay0129/repos","events_url":"https://api.github.com/users/hdjay0129/events{/privacy}","received_events_url":"https://api.github.com/users/hdjay0129/received_events","type":"User","site_admin":false},"created_at":"2018-11-23T14:03:05Z","updated_at":"2018-11-23T14:03:05Z","author_association":"NONE","body":"I got to know from @novabyte that's it's a system user with those empty string username value inserted on migrate up. \r\nSo now the issue is, \r\n\r\n> sending empty string as usernames allows one to add a system user as friend\r\n\r\n which should not be happening."}}
{"actor":{"display_login":"hdjay0129"}}