invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
170 stars 47 forks source link

[bug]: Format execption is always thrown when running flutterfire configure #262

Closed stMerlHin closed 5 months ago

stMerlHin commented 6 months ago

Is there an existing issue for this?

This is releated to #237. Opening new issue because the stack trace and the CLI version are different.

CLI Version

0.3.0-dev.19

Firebase Tools version

13.4.0

Node version

v21.6.2

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.19.1, on Kali GNU/Linux Rolling 6.6.9-amd64, locale fr_FR.UTF-8) • Flutter version 3.19.1 on channel stable at /opt/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision abb292a07e (il y a 13 jours), 2024-02-20 14:35:05 -0800 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /opt/Android/Sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /opt/android-studio/jbr/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.

[✓] Chrome - develop for the web • CHROME_EXECUTABLE = /usr/bin/chromium

[✓] Linux toolchain - develop for Linux desktop • Debian clang version 16.0.6 (19) • cmake version 3.28.3 • ninja version 1.11.1 • pkg-config version 1.8.1

[✓] Android Studio (version 2022.3) • Android Studio at /opt/android-studio • Flutter plugin version 75.1.2 • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version openjdk version "17.0.6" 2023-01-17

[✓] IntelliJ IDEA Community Edition (version 2023.2) • IntelliJ at /opt/idea-IC-232.10072.27 • Flutter plugin version 77.1.3 • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available) • Linux (desktop) • linux • linux-x64 • Kali GNU/Linux Rolling 6.6.9-amd64 • Chrome (web) • chrome • web-javascript • Chromium 121.0.6167.160 built on Debian trixie/sid, running on Debian kali-rolling

[✓] Network resources • All expected network resources are available.

• No issues found!

Description

Failed to parse JSON response from Firebase CLI. JSON response: {
  "status": "success",
  "result": [
    {
      "projectId": "procject-id",
      "projectNumber": "2380",
      "displayName": "Display",
      "name": "projects/project-id",
      "resources": {
        "hostingSite": "project-id",
        "storageBucket": "project-id.appspot.com",
        "locationId": "europe-west"
      },
      "state": "ACTIVE",
      "etag": "1_c74d64e0-ba66-42e6-88se-303ds3222dsds"
    },
    {
      "projectId": "rtc-test-94090",
      "projectNumber": "978336444",
      "displayName": "rtc-test",
      "name": "projects/rtc-test-9848",
      "resources": {
        "hostingSite": "rtc-test-93d9839"
      },
      "state": "ACTIVE",
      "etag": "1_81c10fa0-f712-4cbf-b0fd-e35e0403094"
    }
  ]
}{
  "status": "error",
  "error": "Timed out."
}
FormatException: Unexpected character (at line 29, character 2)
}{

Steps to reproduce

  1. run flutterfire configure in flutter root project
  2. Format exception will be thrown

Expected behavior

Show list of firebase projects.

Screenshots

No response

Additional context and comments

The issue comes from these lines }{ "status": "error", "error": "Timed out." } which are parts of response returned by the firebase tools. The are always appended to the response and make the CLI always throw format exception. I tried to remove these lines from the response but the value of process.exitCode from : https://github.com/invertase/flutterfire_cli/blob/32fde77008b5a28d6ba856dae9f7a678dc0fbe0d/packages/flutterfire_cli/lib/src/firebase.dart#L116-L121 is 2 and process.stderr is

(node:6744) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
stMerlHin commented 6 months ago

@KartikShrivastava, does the latest version (0.3.0-dev.19) of the flutterfire_cli fix the issue for you ? Actually, it does not for me. I am using my own version of the cli which contain a fix i wrote...

stMerlHin commented 6 months ago

Just pinging you @russellwheatley about this.

KartikShrivastava commented 6 months ago

@KartikShrivastava, does the latest version (0.3.0-dev.19) of the flutterfire_cli fix the issue for you ? Actually, it does not for me. I am using my own version of the cli which contain a fix i wrote...

@stMerlHin, not sure why am I tagged here, can you elaborate?

stMerlHin commented 6 months ago

@KartikShrivastava, does the latest version (0.3.0-dev.19) of the flutterfire_cli fix the issue for you ? Actually, it does not for me. I am using my own version of the cli which contain a fix i wrote...

@stMerlHin, not sure why am I tagged here, can you elaborate?

You were facing the same issue I reported at #237 and used the workaround I posted some times ago. I wonder if you have upgraded the cli to the latest version and if It solved the issue for you.

KartikShrivastava commented 6 months ago

Ah thanks for reminding @stMerlHin, I'm using this combination of versions right now:

Flutter version: Flutter 3.7.0 • channel stable
Dart SDK version: 2.19.0
Android JDK version: 17
Android gradle version: gradle-7.2.2-all
gradle-wrapper.properties distributionUrl: https://services.gradle.org/distributions/gradle-7.5-all.zip
Flutterfire CLI: [0.3.0-dev.18](https://github.com/invertase/flutterfire_cli/archive/refs/tags/flutterfire_cli-v0.3.0-dev.18.tar.gz)
Node version: v21.3.0
Firebase-tools: 11.2.2

I wonder if you have upgraded the cli to the latest version and if It solved the issue for you

No, I haven't upgraded the cli version

russellwheatley commented 6 months ago

I've just tested on a fresh flutter app and was not able to reproduce I'm afraid. I even tried to parse the JSON object you provided using a Dart script and it parsed correctly.

stMerlHin commented 6 months ago

This is curious. Are you sure you tried to parse this JSON?

  {
  "status": "success",
  "result": [
    {
      "projectId": "procject-id",
      "projectNumber": "2380",
      "displayName": "Display",
      "name": "projects/project-id",
      "resources": {
        "hostingSite": "project-id",
        "storageBucket": "project-id.appspot.com",
        "locationId": "europe-west"
      },
      "state": "ACTIVE",
      "etag": "1_c74d64e0-ba66-42e6-88se-303ds3222dsds"
    },
    {
      "projectId": "rtc-test-94090",
      "projectNumber": "978336444",
      "displayName": "rtc-test",
      "name": "projects/rtc-test-9848",
      "resources": {
        "hostingSite": "rtc-test-93d9839"
      },
      "state": "ACTIVE",
      "etag": "1_81c10fa0-f712-4cbf-b0fd-e35e0403094"
    }
  ]
}{
  "status": "error",
  "error": "Timed out."
}

There is no way this can be a valid JSON. These lines

{
  "status": "error",
  "error": "Timed out."
}

are appended to the response.

russellwheatley commented 6 months ago

The JSON response is:

{
  "status": "success",
  "result": [
    {
      "projectId": "procject-id",
      "projectNumber": "2380",
      "displayName": "Display",
      "name": "projects/project-id",
      "resources": {
        "hostingSite": "project-id",
        "storageBucket": "project-id.appspot.com",
        "locationId": "europe-west"
      },
      "state": "ACTIVE",
      "etag": "1_c74d64e0-ba66-42e6-88se-303ds3222dsds"
    },
    {
      "projectId": "rtc-test-94090",
      "projectNumber": "978336444",
      "displayName": "rtc-test",
      "name": "projects/rtc-test-9848",
      "resources": {
        "hostingSite": "rtc-test-93d9839"
      },
      "state": "ACTIVE",
      "etag": "1_81c10fa0-f712-4cbf-b0fd-e35e0403094"
    }
  ]
}

The other object is not part of the JSON output, it is other output perhaps from the rethrow.

stMerlHin commented 6 months ago

The other object is part of the response, this is why a format exception is thrown. The description I provided is the raw output of the CLI. It comes from this. https://github.com/invertase/flutterfire_cli/blob/32fde77008b5a28d6ba856dae9f7a678dc0fbe0d/packages/flutterfire_cli/lib/src/firebase.dart#L104-L114 You can notice that the JSON is printed from the catch block when an exception occurred. The output of the rethrow is this FormatException: Unexpected character (at line 29, character 2) }{.

stMerlHin commented 6 months ago

A screen record which shows the whole process from installation to configuration of a project

Capture vidéo du 2024-03-12 20-14-30.webm

russellwheatley commented 6 months ago

hmmmm, not sure why it is timing out and I can't reproduce. You could possibly make me a "viewer" on the project or create another throwaway Firebase project and reproduce the issue, and make me a "viewer" so I can try to replicate on my end. Otherwise, I can't fix it without reproducing.

russellwheatley commented 5 months ago

@stMerlHin - ok, I think I understand the problem. Thanks for raising the issue 👍