firebase-admin-java
firebase-admin-java copied to clipboard
Running a native image on GCP (Cloud Run) throws error 400
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: https://github.com/GoogleCloudPlatform/native-image-support-java/issues/116 for the old google native support libraries. Their workarounds didn't work for me.
Are there any know solutions? Thanks
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
This usually occurs when you do not set the token of the user on your request. Is this issue solved on your side by now?
PS: @TMSantos What is the reason for excluding grpc-netty-shaded
from the dependencies?
I am also having issues with building the native image after adding this dependency.