question

cartellonegerardo avatar image
cartellonegerardo asked

Deleted a shared group Data yet there is still key in it's dictionary. could this be a bug?

Normally when I try to access a shared group Data that doesn't exist I get an error code: PlayFabErrorCode.NotAuthorized.

But for this specific shared group data with the id:.E73426F63FC7A5CD68F981EEC50CA4B8 I get no error when trying to access it with the unity client GetSharedGroupData(). But normally I have deleted it.

When I look it up with the developer console at: https://developer.playfab.com/

there is one random variable in the dictionary left yet there is no members and non of the other variables that where there when I created the group. When i try to deleted it or remove the last key remaining it tells me error i can't because there is no members.

in this next picture the shared group data has being recreated there are members but at first there are no keys

whether I add keys or not after I delete the shared group data it goes back to picture one:

more info :

azur cloud function used to create the group data:

[FunctionName("acceptChat")] 
        public static async Task<IActionResult> acceptChat(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# acceptChat function processed a request.");
            FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
            var args = context.FunctionArgument;
            var entityProfile = context.CallerEntityProfile;
            EntityKey masterPlayerAccountEntity = new EntityKey()
            {
                Id = entityProfile.Lineage.MasterPlayerAccountId,
                Type = "master_player_account"
            };
            var dataApi = GetDataAPI(context);
            //ClassConverter<PlayFab.ProfilesModels.EntityKey, PlayFab.DataModels.EntityKey>.Convert(entityProfile.Entity)
            var getObjectsResponse = await GetObjects(masterPlayerAccountEntity, dataApi);
            var getObjectsResult = getObjectsResponse.Result.Objects;

            List<AskToChatRequest> listChatRequests = null;
            PlayFabResult<SetObjectsResponse> setResponse = null;
            AskToChatRequest requestAccepted = null;
            if (getObjectsResponse.Result.Objects.Count != 0)
            {
                var chatRequestObject = getObjectsResponse.Result.Objects["ChatRequests"];
                var chatRequests = chatRequestObject.DataObject;
                listChatRequests = JsonConvert.DeserializeObject<List<AskToChatRequest>>(chatRequests.ToString());
                bool foundRequest = false;

                for (int i = 0; i < listChatRequests.Count; i++)
                {
                    if (listChatRequests[i].idOfChatAsker == ((string)args.askerId))
                    {
                        foundRequest = true;
                        listChatRequests[i].state = "accepted";
                        requestAccepted = listChatRequests[i];
                        break;
                    }
                }
                if (foundRequest)
                {
                    var serverApi = GetServerAPI(context);
                    requestAccepted.groupDataId = requestAccepted.idOfChatAsker + entityProfile.Lineage.MasterPlayerAccountId;
                    requestAccepted.idOfRequestReceiver = entityProfile.Lineage.MasterPlayerAccountId;
                    var requestCreat = new PlayFab.ServerModels.CreateSharedGroupRequest()
                    {
                        SharedGroupId = requestAccepted.groupDataId
                    };
                    var resultCreat = await serverApi.CreateSharedGroupAsync(requestCreat);

                    List<String> MemebersIds = new List<string>();
                    MemebersIds.Add(requestAccepted.idOfChatAsker);
                    MemebersIds.Add(entityProfile.Lineage.MasterPlayerAccountId);

                    var requestAddMember = new PlayFab.ServerModels.AddSharedGroupMembersRequest()
                    {
                        PlayFabIds = MemebersIds,
                        SharedGroupId = requestAccepted.groupDataId
                    };

                    var resultAddMember = await serverApi.AddSharedGroupMembersAsync(requestAddMember);


                    setResponse = await SetObjects(masterPlayerAccountEntity, dataApi, "ChatRequests", listChatRequests);


                }
            }

            return new OkObjectResult(new
            {
                getResult = requestAccepted,
            });
        }

azur cloud function used to delete the group data:

[FunctionName("leaveChat")]
        public static async Task<IActionResult> leaveChat(
             [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
             ILogger log)
        {
            log.LogInformation("C# leaveChat function processed a request.");
            FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
            var args = context.FunctionArgument;
            var entityProfile = context.CallerEntityProfile;
            var serverApi = GetServerAPI(context);
            var requestDeleteSharedData = new PlayFab.ServerModels.DeleteSharedGroupRequest()
            {
                SharedGroupId = ((string)args.groupDataId)
            };

            var resultDeleteSharedData = await serverApi.DeleteSharedGroupAsync(requestDeleteSharedData);
            return new OkObjectResult(new
            {
                getResult = resultDeleteSharedData
            });
        }

this next script is the unity client function used to get data from the shared group data here i get "found no data" printed in the consol when attempting to access the group data that doesn't exist E73426F63FC7A5CD68F981EEC50CA4B8 but for other group data that doesn't exist i get "failed to get message: " + error"

  async Task<GetSharedGroupDataResult> GetSharedGroupDataGame(string fullDataName)
    {
        Debug.Log("GetSharedGroupDataGame() called");
        TaskCompletionSource<bool> functionOperating = new TaskCompletionSource<bool>();
        GetSharedGroupDataResult sharedDataFound = null;
        int contextCalled = contextId;
        var request = new GetSharedGroupDataRequest()
        {
            SharedGroupId = chatGroupIn,
            Keys = new List<string> { (fullDataName) },
            GetMembers = false
        };
        PlayFabClientAPI.GetSharedGroupData(request, (GetSharedGroupDataResult result) => {
            if (result.Data != null && result.Data.ContainsKey(fullDataName) && result.Data[fullDataName] != null)
            {
                sharedDataFound = result;
                Debug.Log("found data");
            }
            Debug.Log("found no data");
            functionOperating.SetResult(true);


        }, (PlayFabError error) => {
            if (contextCalled == contextId && error.Error == PlayFabErrorCode.NotAuthorized)
            {
                AutoLeaveChat();
            }
            Debug.Log("failed to get message: " + error);
            functionOperating.SetResult(true);
        });
        await functionOperating.Task;
        return sharedDataFound;
    }

Thanks for any help.

Shared Group Data
ldykl.png (125.8 KiB)
wtauz.png (157.6 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image
Made Wang answered

To clarify, PlayFabErrorCode.NotAuthorized is not an error message returned by GetSharedGroupData. This error is usually related to session credentials or login.

The client GetSharedGroupData has no error codes so even if the shared group data you are accessing does not exist or the shared group does not exist, it will not return an error. The error callback will only be executed when some http error occurs, or you are not logged in.

Regarding the error "This group data must have at least one member." this is by design, when everyone leaves, you should delete this shared group.

You have a lot of customization in your code, and I can't test it, you can try some quick tests with Postman.

Also, feel free to post a feature request if you want GetSharedGroupData to return more error messages.

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cartellonegerardo avatar image cartellonegerardo commented ·

thanks for your help so far. So i checked a few more times and indeed it's kinda just random when i get the PlayFabErrorCode.NotAuthorized could be only linked to the corrupted data group but i'm not sure.

In any case I'm a bit concerned about what appears to be corrupt data with the shared group of id: E73426F63FC7A5CD68F981EEC50CA4B8 from my title with id 22A50

After deleting the shared group data keys remain. Since last time there is a new key that remains after the group was deleted.

I'm not sure if this is going to be to useful:

but here is my code that creates the group data then changes keys then deletes it it's not exactly the same code that caused what appears to me to be corruption but it stands on its own.

https://drive.google.com/file/d/1eAZjNrMw8X0p8JKU7yPvVKcPUx0IzWbj/view?usp=sharing

then here are the azure functions that go with it:

https://drive.google.com/file/d/13e2jYSPXZyi2gVUVtKZDzDWltP2EsNCr/view?usp=sharing

0 Likes 0 ·
lv7w6.png (125.7 KiB)
Made Wang avatar image Made Wang cartellonegerardo commented ·

I tested your code, PlayFabErrorCode.NotAuthorized is because TestCreateSharedGroup has not been fully executed when you execute SetKey, for example, Shared Group has been created but members have not been added. You can wait a little longer or execute SetKey in the success callback of TestCreateSharedGroup.

Do you mean that you now have a Shared Group that cannot be deleted? Can you get this data?

I see that you have some error messages for DeleteSharedGroup/InvalidSharedGroupId. Have you tried using postman to test? And can I do some tests on your Title?

0 Likes 0 ·
cartellonegerardo avatar image cartellonegerardo Made Wang commented ·

Thanks good to know where the PlayFabErrorCode.NotAuthorized comes from. I haven't tried using postman I would not know what exactly to do with it.

I don't know what it is exactly that remains in the data all I see is when I type in the specific shared group data id at https://developer.playfab.com/en-us/22A50/shared-group-data. I see two keys and I can't delete them and i can't delete the group data either. I haven't tried attempting to get the lingering data yet.

Practically speaking everything seems to work fine despite the lingering data.

But I thought it was a source for concern and maybe useful for playfab devs.

Yes if you want you can do tests on my title.

0 Likes 0 ·
Show more comments
Show more comments
Made Wang avatar image
Made Wang answered

Does this issue still exist and if so I will report the issue to development.

Also, do you have permission to submit a ticket? If so, you can submit a ticket yourself to resolve the issue faster.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cartellonegerardo avatar image cartellonegerardo commented ·

I think it still exists. I still see those keys that shouldn't exist are still there but I can't be sure that if I were to change the shared group data things would go back to normal after I delete it. Currently my free azure function subscription ended so I can't test any functions. I'm trying to restart my subscription somehow I have being asking question to the azure people about that. Also I don't have permission to submit tickets.

0 Likes 0 ·
Made Wang avatar image Made Wang cartellonegerardo commented ·

I want to do some tests to make sure the problem still exists. I created an account in your Title, PlayFabId: 10B28EB56A8CAC74. Can you add me to Group:E73426F63FC7A5CD68F981EEC50CA4B8? I will try to delete the data in it.

Also, you can refer to Quickstart PlayFab REST API collection for Postman - PlayFab | Microsoft Docs to use postman, and you can use it to call DeleteSharedGroup.

0 Likes 0 ·
cartellonegerardo avatar image cartellonegerardo Made Wang commented ·

I setup postman and I tried to add you to the Group: E73426F63FC7A5CD68F981EEC50CA4B8 but I get this as response:

{
 "code": 400,
 "status": "BadRequest",
 "error": "InvalidSharedGroupId",
 "errorCode": 1088,
 "errorMessage": "InvalidSharedGroupId"
<br>

more info on my request:

Post: https://{ {TitleId}}.playfabapi.com/Server/AddSharedGroupMembers?sdk=PostmanCollection-0.150.220509

body:

{
 "SharedGroupId": "E73426F63FC7A5CD68F981EEC50CA4B8",
 "PlayFabIds": [
 "10B28EB56A8CAC74"
 ]
}

just to make sure I had setup all the things right in postman I tried to make another test shared group data called 'Clan Data' and added a member to it and I had no errors everything worked fine. I can see that group data in the developer portal. So i guess I set up Postman correctly.

If I recreate the group I think i'll be able to add you to it shall I do that?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.