Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Failed to write android google-services.json file on CI when using flutterfire reconfigure #365

Open
1 task done
AhmedLSayed9 opened this issue Jan 17, 2025 · 9 comments
Labels
bug Something isn't working Needs Attention OP created or responded to issue and it needs attention.

Comments

@AhmedLSayed9
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues.

CLI Version

1.0.1

Firebase Tools version

13.29.1

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.24.3, on macOS 15.2 24C101 darwin-arm64, locale en-EG)
• Flutter version 3.24.3 on channel stable at /Users/ahmedelsayed/.puro/envs/locals/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184aa7 (4 months ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3

Description

When using Firebase service account JSON file and use flutterfire reconfigure instead of flutterfire configure on CI, it fails.

This was requested before at #232

Steps to reproduce

Add Firebase service account JSON to your secrets and try running the following on CI:

  • name: Add Firebase service account credentials files
    env:
    FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
    run: |
    echo $FIREBASE_SERVICE_ACCOUNT > /tmp/google-application-credentials.json
  • name: Configure Firebase
    env:
    GOOGLE_APPLICATION_CREDENTIALS: /tmp/google-application-credentials.json
    run: flutterfire configure ...... // Complete your project configurations

It should run successfully, but If you use flutterfire reconfigure, it'll fail with the following error:

Failed to write android google-services.json file write for build configuration: "src/dev". Please report this issue at:https://github.com/invertase/flutterfire_cli. Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

Expected behavior

I expect flutterfire reconfigure to work on CI.

Screenshots

No response

Additional context and comments

No response

@AhmedLSayed9 AhmedLSayed9 added bug Something isn't working triage labels Jan 17, 2025
@russellwheatley
Copy link
Member

@AhmedLSayed9 - Is there a stack trace to go with it?

What does your firebase.json look like for android, specifically for this build configuration src/dev. Redact any sensitive strings, only concerned with structure.

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed triage labels Jan 24, 2025
@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Jan 24, 2025
@AhmedLSayed9
Copy link
Contributor Author

What does your firebase.json look like for android, specifically for this build configuration src/dev. Redact any sensitive strings, only concerned with structure.

{
  "flutter": {
    "platforms": {
      "android": {
        "buildConfigurations": {
          "src/dev": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "fileOutput": "android/app/src/dev/google-services.json"
          },
          "src/staging": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "fileOutput": "android/app/src/staging/google-services.json"
          },
          "src/prod": {
            "projectId": "REDACTED_PROJECT_ID_PRODUCTION",
            "appId": "REDACTED_APP_ID_PRODUCTION",
            "fileOutput": "android/app/src/prod/google-services.json"
          }
        }
      },
      "ios": {
        "buildConfigurations": {
          "Debug-dev": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/dev/GoogleService-Info.plist"
          },
          "Profile-dev": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/dev/GoogleService-Info.plist"
          },
          "Release-dev": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/dev/GoogleService-Info.plist"
          },
          "Debug-staging": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/staging/GoogleService-Info.plist"
          },
          "Profile-staging": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/staging/GoogleService-Info.plist"
          },
          "Release-staging": {
            "projectId": "REDACTED_PROJECT_ID",
            "appId": "REDACTED_APP_ID",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/staging/GoogleService-Info.plist"
          },
          "Debug-prod": {
            "projectId": "REDACTED_PROJECT_ID_PRODUCTION",
            "appId": "REDACTED_APP_ID_PRODUCTION",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/prod/GoogleService-Info.plist"
          },
          "Profile-prod": {
            "projectId": "REDACTED_PROJECT_ID_PRODUCTION",
            "appId": "REDACTED_APP_ID_PRODUCTION",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/prod/GoogleService-Info.plist"
          },
          "Release-prod": {
            "projectId": "REDACTED_PROJECT_ID_PRODUCTION",
            "appId": "REDACTED_APP_ID_PRODUCTION",
            "uploadDebugSymbols": true,
            "fileOutput": "ios/config/prod/GoogleService-Info.plist"
          }
        }
      },
      "dart": {
        "lib/firebase_options_dev.dart": {
          "projectId": "REDACTED_PROJECT_ID",
          "configurations": {
            "android": "REDACTED_APP_ID",
            "ios": "REDACTED_APP_ID"
          }
        },
        "lib/firebase_options_staging.dart": {
          "projectId": "REDACTED_PROJECT_ID",
          "configurations": {
            "android": "REDACTED_APP_ID",
            "ios": "REDACTED_APP_ID"
          }
        },
        "lib/firebase_options_prod.dart": {
          "projectId": "REDACTED_PROJECT_ID_PRODUCTION",
          "configurations": {
            "android": "REDACTED_APP_ID_PRODUCTION",
            "ios": "REDACTED_APP_ID_PRODUCTION"
          }
        }
      }
    }
  }
}

@github-actions github-actions bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jan 24, 2025
@AhmedLSayed9
Copy link
Contributor Author

Image

@russellwheatley
Copy link
Member

Have you reproducing locally?

It's going to be one of these if it is android I think:

https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/commands/reconfigure.dart#L393
https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/commands/reconfigure.dart#L415

Is the firebase.json in the root of the project?

The firebase.json configuration seems correct to me. A local repro would be helpful.

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention OP created or responded to issue and it needs attention. labels Jan 24, 2025
@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Jan 24, 2025
@AhmedLSayed9
Copy link
Contributor Author

flutterfire reconfigure works fine locally

@github-actions github-actions bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jan 24, 2025
@AhmedLSayed9
Copy link
Contributor Author

The difference is locally I'm logged in using firebase login but at the CI I'm using firebase service account credentials.

@AhmedLSayed9
Copy link
Contributor Author

Is the firebase.json in the root of the project?

Yes

@russellwheatley
Copy link
Member

The difference is locally I'm logged in using firebase login but at the CI I'm using firebase service account credentials.

I don't think this should make a difference. Not sure what the problem is, It's saying something that is expected to be a map (from those lines I pasted earlier), is null.

You ought to put some debug logs on firebase.json path, content, etc to find out why map is empty. It's clearly a difference between your CI and local environment.

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention OP created or responded to issue and it needs attention. labels Jan 24, 2025
@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Jan 24, 2025
@AhmedLSayed9
Copy link
Contributor Author

@russellwheatley

I was able to reproduce it using a minimal sample: https://github.com/AhmedLSayed9/firebase_test

Check the workflow: https://github.com/AhmedLSayed9/firebase_test/actions/runs/12951734235/job/36127428141

To reproduce:

  1. Clone the repo, add a firebase project to it and update firebase.json file.
  2. Add an environment secret to your repo that includes the service account json with the name FIREBASE_SERVICE_ACCOUNT.
  3. Update --project=test-c7826 at .github/workflows/build.yml to your project id.
  4. Try running the CI workflow

@github-actions github-actions bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs Attention OP created or responded to issue and it needs attention.
Projects
None yet
Development

No branches or pull requests

2 participants