firebase / quickstart-cpp

Firebase Quickstart Samples for C++
https://firebase.google.com/games
Apache License 2.0
206 stars 122 forks source link

[Android] Cloud Functions returning arrays are not correctly parsed #32

Closed jpoag closed 5 years ago

jpoag commented 5 years ago

Reproduction source code: #31

Operating system: Android Operating system version: minSDK: 14,15,16 buildSDK:26 & 27 C++ SDK: 5.2.0 & 5.1.1 Dependencies: implementation 'com.google.firebase:firebase-functions:16.1.0'

What steps will reproduce the problem:

  1. Using firebase/functions, call a Cloud function that returns an array (filled) as the value of the data return... E.g:
exports.echoBody = functions.https.onRequest((request, response) => {
    response.status(200);
    response.json({ data : ['this', 'is' 1, 'test'] } );
});
  1. When the future completes, check the result->data() variant. It is kNullType

What is the expected result? Using the iOS SDK, the result is the array.

What happens instead of that? Null is returned. I suspect that the parsing of array/vectors are not implemented or are interpreted differently.

Please provide any other information below, and attach a screenshot if possible. I stumbled across this issue implementing server side receipt checking for IAB. I use a 3rd party source that returns the validated receipt as an array of objects, each object representing a SKU (+State). For iOS, this works perfectly. When implementing the same calls for Android, I get a null response. I debugged both sides of the app, including turning on logging for my Cloud functions to log the return value. I even checked using Postman: the server response is valid.

Next, I forked quickstart-cpp, cloned the database example and re-purposed it to test Cloud Functions (See #31). The tests all run correctly (even with the Int64/Double issue) with the exception of Arrays/Vectors returning null. (See functions/testapp/src/common_main.cc )

jpoag commented 5 years ago

Per Firebase Support, I have changed the echoBody on the server from onRequest to onCall 655401dadee09f182ddc023e09eec196acf55b6c .

The issue still persists. I have caught the following warning in LogCat:

W/firebase: Class java.util.ArrayList cannot be converted to Variant, leaving empty.

I maintain that this is a Android-specific, C++ error.

alexames commented 5 years ago

Hi jpoag, we've identified the bug and have a fix in the works. The fix should be rolled out in an update in the near future.

jpoag commented 5 years ago

Ok, great. Thanks!

On Wed, Sep 5, 2018, 1:39 PM Alex Ames notifications@github.com wrote:

Hi jpoag, we've identified the bug and have a fix in the works. The fix should be rolled out in an update in the near future.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-cpp/issues/32#issuecomment-418817256, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUKsPqo04k_gaVn4n-_dYRsQNMFiQwSks5uYAxCgaJpZM4VunCJ .

jpoag commented 5 years ago

Fixed in 5.3.0: https://firebase.google.com/support/release-notes/cpp-relnotes