Skip to content

Running a native image on GCP (Cloud Run) throws error 400 #860

Open
@TMSantos

Description

@TMSantos

Hi,

Compiling to native this dependency:

<dependency>
      <groupId>com.google.firebase</groupId>
      <artifactId>firebase-admin</artifactId>
      <version>9.2.0</version>
</dependency>

makes the build fail because grpc-netty-shaded, however with this alternative we can compile:

<!-- FCM -->
    <dependency>
      <groupId>com.google.firebase</groupId>
      <artifactId>firebase-admin</artifactId>
      <version>9.2.0</version>
      <exclusions>
        <exclusion>
          <groupId>io.grpc</groupId>
          <artifactId>grpc-netty-shaded</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!--Using OkHttp over netty because the shaded netty included in grpc does not work with native image-->
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-okhttp</artifactId>
      <version>1.51.1</version>
    </dependency>

The problem is that FCM client always responds with error 400:

Exception in thread "main" com.google.firebase.messaging.FirebaseMessagingException: Unexpected HTTP response with status: 400
{
  "error": {
    "code": 400,
    "message": "Recipient of the message is not set.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "message",
            "description": "Recipient of the message is not set."
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
        "errorCode": "INVALID_ARGUMENT"
      }
    ]
  }
}

Running on JVM works fine.
There is a issue with same problem: GoogleCloudPlatform/native-image-support-java#116 for the old google native support libraries. Their workarounds didn't work for me.

Are there any know solutions?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions