Skip to content

Insufficient error handling in vendor/symfony/firebase-notifier/FirebaseTransport.php #42841

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

Closed
fabbaumgartner opened this issue Sep 2, 2021 · 5 comments

Comments

@fabbaumgartner
Copy link

fabbaumgartner commented Sep 2, 2021

Symfony version(s) affected: 5.3.4
Symfony/firebase-notifier version(s) affected: 5.3.4

Description
Insufficient error handling in doSend() method in vendor/symfony/firebase-notifier/FirebaseTransport.php

How to reproduce
Send a firebase request with an timed out token

Possible Solution
Correct error verification to catch errors, also take return values failure/success into account

Additional context
The error catching part:
if ($jsonContents && isset($jsonContents['results']['error'])) { throw new TransportException('Unable to post the Firebase message: '.$jsonContents['error'], $response); }

Does not catch errors returned by firebase:
array:5 [ "multicast_id" => 0101010101010101010 "success" => 0 "failure" => 1 "canonical_ids" => 0 "results" => array:1 [ 0 => array:1 [ "error" => "NotRegistered" ] ] ]

@OskarStark
Copy link
Contributor

Looks like this can be improved.

Open for a PR? 😃

@fabbaumgartner
Copy link
Author

Honestly.. I don't know the Symfony coding or PR guidelines

@dmaicher
Copy link
Contributor

dmaicher commented Sep 2, 2021

Honestly.. I don't know the Symfony coding or PR guidelines

Its not that complicated 😉

Just have a look at https://symfony.com/doc/current/contributing/code/pull_requests.html and start contributing 😎

@Nyholm
Copy link
Member

Nyholm commented Sep 6, 2021

Just send a "normal PR" and we are happy to help you if something is missing.

If you feel like you want to try sending a PR to Symfony another time, then just let this thread know so someone else can work on a fix.

@villfa
Copy link
Contributor

villfa commented Oct 12, 2021

It's related to #42690, but I think there is still an issue (['results']['error'] instead of ['results'][0]['error']):

$errorMessage = $jsonContents ? $jsonContents['results']['error'] : $response->getContent(false);

@fabpot fabpot closed this as completed Oct 12, 2021
fabpot added a commit that referenced this issue Oct 12, 2021
…sport (villfa)

This PR was merged into the 5.3 branch.

Discussion
----------

[Notifier] Fix 'Undefined array key' error in FirebaseTransport

| Q             | A
| ------------- | ---
| Branch?       | 5.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #42841
| License       | MIT
| Doc PR        | n/a

This modification fixes a remaining `Undefined array key` error in *FirebaseTransport*.
It also add a test to cover #42690.

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 5.x.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->

Commits
-------

53f836e [Notifier] Fix 'Undefined array key' error in FirebaseTransport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants