question

Nikolai avatar image
Nikolai asked

Cloud scripts returns an object with empty fields

Hello PlayFab team!

I have an issue with running my CloudScript functions from PlayFab website.

When I am trying to run any function from Cloud Scripts tab I always get an object with empty fields please see image bellow.

Hovewer If I send a request to some PlayFab title by Postman or from our game it works fine.

Could you please help me with this issue?

CloudScript
6pf0n.png (83.6 KiB)
9 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.

Nikolai avatar image Nikolai commented ·

Best regards,

Nikolai

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Nikolai commented ·

Could you please provide us the Title Id for the analysis?

0 Likes 0 ·
Nikolai avatar image Nikolai Sarah Zhang commented ·

Hello Sarah,

Sure, the title is 147AA.

Best regards,
Nikolai

0 Likes 0 ·
Show more comments
James Battersby avatar image James Battersby commented ·

I was wondering if it was just me. Same issue with title ID: 429FA

0 Likes 0 ·
James Battersby avatar image James Battersby James Battersby commented ·

Except I get this from the client calls also

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang commented ·

In our test, it won't affect the client result. If you also get the empty arrays in the client after calling ExecuteCloudScript. Could you please provide the reproduced steps? Which one function caused this issue? What is the expected behavior? And is there any error message?

0 Likes 0 ·
James Battersby avatar image James Battersby Sarah Zhang commented ·

Sadly not anymore as I found discrepancies in the cloudscript that was producing errant result and have since corrected it. So it's likely that it was returning an empty string.

That being said, I'm almost certain that when I had left it from the previous weekend things were working as expected or in the very least producing an error result if it was an empty string which would have been a custom object with some relevant information.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang James Battersby commented ·

We can reproduce this issue when the functions output Json Objects. We will try to inform our engireing team this issue for the investigation. You can use the workaround mentioned in the answer temporarily.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

We will try to inform our team this issue for the investigation. Currently, to display the Json Objects returned by CloudScript in the Game Manager's [CloudScript] page, the possible workaround is converting the Json Object to the string.

log.info(JSON.stringify([the json object you want to output]));

Example

handlers.helloWorld = function (args, context) {

    var message = "Hello " + currentPlayerId + "!";

    log.info(message);
    var inputValue = null;
    if (args && args.inputValue)
        inputValue = args.inputValue;
    log.debug("helloWorld:", JSON.stringify({ input: args.inputValue }));

    var resultStrobj = { "messageValue": message };
    var resultStr = JSON.stringify(JSON.stringify(resultStrobj));

    return resultStr;
};
10 |1200

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

Mauricio Ferreira avatar image
Mauricio Ferreira answered

Hello. I have the same issue. This start to occurred yesterday for me too.

1 comment
10 |1200

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

Sarah Zhang avatar image Sarah Zhang commented ·

We can reproduce this issue when the returned value is an empty string. And this behavior wouldn't affect the response in the client. Is it your case too?

0 Likes 0 ·
Vadim Assachyov avatar image
Vadim Assachyov answered

Hi!

Real result is normal (tested in postman), but not result on playfab CloudScript tab, as wrote Nikolay. For testing purpose i often look into this CloudScript tab, and some time ago (till now) i start getting empty brackets response.

It looks like a playfab wrong displaying function result at CloudScript tab.

1 comment
10 |1200

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

Sarah Zhang avatar image Sarah Zhang commented ·

Thanks for the report. You can use the workaround mentioned in the answer temporarily.

0 Likes 0 ·
Gadiraju Sanjay Varma avatar image
Gadiraju Sanjay Varma answered
2 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.

Sarah Zhang avatar image Sarah Zhang commented ·

This issue is related to the method PlayFab uses to return the function result. We will inform our team to investigate it. Currently, you can use the following workaround to display the information.

To display the CloudScript output information in the player's [CloudScript] page, you can convert the Json Objects to the Json String firstly, then output them. The code could be something like this.

handlers.helloWorld = function (args, context) {

    var message = "Hello " + currentPlayerId + "!";

    log.info(message);
    var inputValue = null;
    if (args && args.inputValue)
        inputValue = args.inputValue;
    log.debug("helloWorld:", JSON.stringify({ input: args.inputValue }));

    var resultStrobj = { "messageValue": message };
    var resultStr = JSON.stringify(JSON.stringify(resultStrobj));

    return resultStr;
};
0 Likes 0 ·
Gadiraju Sanjay Varma avatar image Gadiraju Sanjay Varma Sarah Zhang commented ·

It is working now.Does it work fine on sdk side in ue4.Thank you

0 Likes 0 ·

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.