feat(fcm): migrate topic subscriptions to FCM v1 API - #3211
lahirumaramba wants to merge 6 commits into
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
There was a problem hiding this comment.
Code Review
This pull request migrates the topic subscription and unsubscription management in the Firebase Messaging service to the FCM v1 API, while preserving the old behavior under deprecated legacy methods. It introduces concurrent request handling with a limit for both HTTP/1.1 and HTTP/2 transports. The review feedback highlights a potential runtime TypeError when parsing server error responses if the error field is null, and identifies an opportunity to reduce code duplication in the task mapping logic for HTTP/1.1 and HTTP/2 requests.
af0393f to
817865e
Compare
b6fca9a to
3d5752b
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the topic subscription management methods (subscribeToTopic and unsubscribeFromTopic) to use the FCM v1 API instead of the legacy Instance ID API, which is now deprecated and moved to legacy methods. It introduces concurrent request handling with support for both HTTP/1.1 and HTTP/2. The reviewer feedback suggests enhancing HTTP/2 error reporting by capturing session-level errors from the session handler and combining them with stream errors using AggregateError inside the response parser to facilitate better debugging.
Migrate `subscribeToTopic` and `unsubscribeFromTopic` methods in `admin.messaging.Messaging` from legacy Instance ID (IID) endpoints (`iid.googleapis.com/iid/v1`) to the modernized single-token Firebase Cloud Messaging (FCM) v1 Topics Subscription REST API (`fcm.googleapis.com/v1`).
- Update `subscribeToTopic` (`CreateTopicSubscription`) and `unsubscribeFromTopic` (`DeleteTopicSubscription`) to use HTTP/2 transport by default (or HTTP/1.1 via `enableLegacyHttpTransport()`).
- Implement client-side concurrency pooling (`runWithConcurrencyLimit`) bounded to 100 concurrent requests per batch to avoid HTTP/2 stream exhaustion.
- Preserve idempotency by treating `ALREADY_EXISTS` (HTTP 409) as success for subscription requests, and `NOT_FOUND` (HTTP 404) as `REGISTRATION_TOKEN_NOT_REGISTERED` for unsubscription requests.
- Add legacy backup/escape-hatch methods `subscribeToTopicLegacy` and `unsubscribeFromTopicLegacy` annotated with `@deprecated Use {@link Messaging.subscribeToTopic} instead.` and `@deprecated Use {@link Messaging.unsubscribeFromTopic} instead.`.
TAG=agy
CONV=a2576aae-730b-4fb1-a151-9e6913f97be4
0f01938 to
679dcd0
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates the topic subscription management methods (subscribeToTopic and unsubscribeFromTopic) to use the FCM v1 API, while preserving the old behavior under new legacy endpoints (subscribeToTopicLegacy and unsubscribeFromTopicLegacy). It also introduces a concurrency-limiting utility to handle batch requests. The review feedback highlights an issue where the UNREGISTERED error code from the FCM v1 API is not correctly mapped to a client-side error, falling back to messaging/unknown-error. The reviewer suggests normalizing UNREGISTERED to NOT_FOUND to ensure proper mapping to messaging/registration-token-not-registered and adding a corresponding unit test to verify this behavior.
…-registered in topic management
Migrate
subscribeToTopicandunsubscribeFromTopicmethods inadmin.messaging.Messagingfrom legacy Instance ID (IID) endpoints (iid.googleapis.com/iid/v1) to the modernized single-token Firebase Cloud Messaging (FCM) v1 Topics Subscription REST API (fcm.googleapis.com/v1).subscribeToTopic(CreateTopicSubscription) andunsubscribeFromTopic(DeleteTopicSubscription) to use HTTP/2 transport by default (or HTTP/1.1 viaenableLegacyHttpTransport()).runWithConcurrencyLimit) bounded to 100 concurrent requests per batch to avoid HTTP/2 stream exhaustion.ALREADY_EXISTS(HTTP 409) as success for subscription requests, andNOT_FOUND(HTTP 404) asREGISTRATION_TOKEN_NOT_REGISTEREDfor unsubscription requests.subscribeToTopicLegacyandunsubscribeFromTopicLegacyannotated with@deprecated Use {@link Messaging.subscribeToTopic} instead.and@deprecated Use {@link Messaging.unsubscribeFromTopic} instead..