FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
98 stars 17 forks source link

JSON data with DocumentReference from Firebase not being decoded. #2842

Open apppbuilder opened 2 weeks ago

apppbuilder commented 2 weeks ago

Has your issue been reported?

Current Behavior

JSON data is not being decoded to DataType when it contains a Document Refence.

Expected Behavior

It should decode everything and return dataType.

Steps to Reproduce

  1. Create a Custom Function.
  2. Send a test data.
  3. The error shows up.

Also, I tried decoding the data with the JSON to DataType and it didn't worked, that's why I got in the Custom Function to check what would be happening.

Reproducible from Blank

Bug Report Code (Required)

IT4gz8rlvJR2rsRE+ZSIbu9ammYUNkN9Rpc0stluZxEoIpznBuw+e8nBdlBWTsjiaVNcfWaWhnkzptLyj9jPOuw7Ay2bG9w/+JZcTjnOe2ijabq0O5aoeEcmI+RXfHKA1sOW3QlSC/hfSGAF12eUPtmiZATDBOu/Zwh9f6PHaOI=

Context

I'm receiving data from Cloud Function POST API, so I need to decode it and start using it. Everything is ok with the Cloud Function, it's sending data and everything, but the data is not showing properly in the app, after lots of tests, found it that it was in the DocReference item.

Visual documentation

image image image

Additional Info

I created an isolated project to check if the problem would persist, and yes, it keeps up.

Also, if you all wanna see the isolated project and check everything, I'll send a bug report code below:

IT4gz8rlvJR2rsRE+ZSIbu9ammYUNkN9Rpc0stluZxEoIpznBuw+e8nBdlBWTsjiaVNcfWaWhnkzptLyj9jPOuw7Ay2bG9w/+JZcTjnOe2ijabq0O5aoeEcmI+RXfHKA1sOW3QlSC/hfSGAF12eUPtmiZATDBOu/Zwh9f6PHaOI=

(the problem isn't in the widget, but in the custom functions while decoding the data)

Environment

FlutterFlow v4.1.45+ released April 25, 2024
Flutter version is 3.19.1
- Platform: Web
- Browser name and version: Chrome latest
- Operating system and version affected: W11

General

Relative to the time the changes were made, data was lost within

When following my steps to reproduce, data loss happens

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

apppbuilder commented 1 week ago

Do not close this issue. Thank you. @ignalauret

ignalauret commented 1 week ago

Hey @apppbuilder thanks for your report. Our technical team has been checking your issue and they said this is not a bug. Apparently the Custom Function test mode doesn't support what you are trying to achieve. In their words:
"This is not a bug. It is a known limitation in custom code. Firestore calls does not work in functions test mode as it does not compile the entire app code.".
So sadly, you are going to have to test them on the Run modes. I will create a feature request to enable this testing, but I don't know when that can get implemented. I'm sorry for the inconvenience, have a great day!

apppbuilder commented 1 week ago

@ignalauret Well... thank you for your reply, but to be honest it's not in the test mode... it's in the real version of the app after deployed. I'll check again and see if it's corrected or not...

Soon I'll be back with more data.

apppbuilder commented 4 days ago

Ok, let's go to real data. @ignalauret

Here is a live app, deployed and in closed testing inside an android smartphone.

The flow is an "on page load" and after calling an API Call that triggers a Cloud Function, it returns some userData to make the app move further.

=========================

### Expected data:

expectedData

=========================

### TheFlow

TestControl TestControlFlowR

I used some "Update App State" to check when it was stopping in the live app.

=========================

### Test 1 — Native decoding

Test1 - 1 Test1 - 2

Results: It stopped in the action before deconding data... (erroState now equals 6)

=========================

### Test 2 — Custom Function decoding

Test2 - 1

Results: = The same... It stopped in the action before deconding data... (erroState now equals 6)

=========================

### Test 3 — Custom Function decoding — WITHOUT DOC REFERENCE

So, to make this happen, I removed the phraseRaf field that was returning from the Cloud Function and also created a new DataType inside Flutterflow:

Test3 - 1

Results: = Now it works perfectly. I printed the image when it turned "7", just to see if it really got through, the rest are simple actions to change the loading screen and it also worked...

=========================

### In the end... — It's not a problem inside Test Mode or Run Mode, it's a general problem while decoding Document Reference from Firebase...