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

fix: adding check for the maximum payload size #346

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geekbrother
Copy link
Contributor

Description

This PR implements a check for the maximum payload size, limiting the size to 4Kb, and throws an appropriate message if exceeding.
The reason for limiting the body payload size is the FCM support payload up to 4Kb.
This should fix the following error:

FcmV1(UnknownHttpResponse { status: 400, body: Ok("{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Android message is too big\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.BadRequest\"\n      },\n      {\n        \"@type\": \"type.googleapis.com/google.firebase.fcm.v1.FcmError\",\n        \"errorCode\": \"INVALID_ARGUMENT\"\n      }\n    ]\n  }\n}\n") })

How Has This Been Tested?

Not tested, but should be covered by the unit and integration tests.

Due Diligence

  • Breaking change
  • Requires a documentation update
  • Requires a e2e/integration test update

@geekbrother geekbrother self-assigned this Jul 24, 2024
@arein arein added the accepted The issue has been accepted into the project label Jul 24, 2024
@geekbrother geekbrother marked this pull request as ready for review July 24, 2024 20:04
> 4096
{
return Err((
Error::PayloadTooLarge("Request body size should not exceed 4Kb".to_string()),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make that inner string part of the display implementation provided by thiserror and you just embed the size of the payload in kb?

Copy link
Member

@chris13524 chris13524 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really an appropriate fix IMO. This is blaming the relay for the payload being too big but the relay is just forwarding messages so it doesn't address the root issue.

Why is the payload too big?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue has been accepted into the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants