8000 [Messenger] Added check if json_encode succeeded by toooni · Pull Request #35137 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Added check if json_encode succeeded #35137

8000 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

Merged
merged 9 commits into from
Jan 7, 2020
Merged

[Messenger] Added check if json_encode succeeded #35137

merged 9 commits into from
Jan 7, 2020

Conversation

toooni
Copy link
Contributor
@toooni toooni commented Dec 29, 2019
Q A
Branch? master
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

When trying to add a message to redis transport which can not be encoded with json_encode there is now a TransportException containing the json_last_error_msg as the message.
I had an issue where I tried to send an email through messenger by symfony mailer which contains a pdf attachment. Instead of an error while sending i got an error Encoded envelope should have at least a "body" which happened because the encoded message was false.

This is not exactly a bugfix, but IMO also not a feature worth being mentioned in the changelog so I am not sure I've filled out the Q/A correctly.

@toooni toooni requested a review from sroze as a code owner December 29, 2019 09:55
@toooni toooni changed the title Added check if json_encode succeeded [messenger] Added check if json_encode succeeded Dec 29, 2019
@toooni toooni changed the title [messenger] Added check if json_encode succeeded [Messenger] Added check if json_encode succeeded Dec 29, 2019
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Dec 30, 2019
Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

for 4.4
can you please send another PR for 4.3, where the code is a bit different?

@toooni
Copy link
Contributor Author
toooni commented Dec 30, 2019

@nicolas-grekas 👍#35150 is targeted to 4.3

@chalasr
Copy link
Member
chalasr commented Dec 31, 2019

Should we do the same for decoding?

@toooni
Copy link
Contributor Author
toooni commented Jan 4, 2020

@chalasr I am not sure. I don't think there is much to gain when doing the same for decoding.

xabbuh and others added 8 commits January 7, 2020 11:39
…llable in container linting (shieldo)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] Handle ServiceClosureArgument for callable in container linting

| Q             | A
| ------------- | ---
| Branch?       | 4.4 (+)
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | (none)
| License       | MIT

Making use of `ServiceClosureArgument` instances in service definitions was not accounted for in container linting when a service type-hints for `callable` in an argument - adding this check ensures that `ServiceClosureArgument` instances are recognised correctly as callables (once they are resolved).

Commits
-------

e48829e [DependencyInjection] Handle ServiceClosureArgument for callable in container linting
…. services (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][ContainerLintCommand] Only skip .errored. services

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This PR partially reverts #34935 that was a kind of a mistake. Skipping all removed ids cannot work because all private services are in the "removed" ids. So the command ends up not validating much.

To still fix the original issue #34858 we need to skip errored services. However, definition errors are not dumped / read (see #34928). So instead, even if it's bad, we can maybe rely on the name for this particular error since it's hardcoded 😕 At least it fixes this case in a simple way 😕

Commits
-------

d38cdc9 [FrameworkBundle][ContainerLintCommand] Only skip .errored. services
…buh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] fix processing chain adapter based cache pool

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35119
| License       | MIT
| Doc PR        |

Commits
-------

8d7fa32 fix processing chain adapter based cache pool
…ure (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] fix exception in case of PSR17 discovery failure

| Q             | A
| ------------- | ---
| Branch?
8000
       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

On symfony.com, we need to use HTTPlug for 3rd party libs. When `nyholm/psr7` is not installed, we currently see an exception saying `No HTTPlug clients found.` from `HttpClientDiscovery`.

This fixes the message by correctly suggesting `nyholm/psr7` instead, since there *is* an HTTPlug client: `HttplugClient` from our HttpClient component.

It's quite unfortunate that `guzzle/psr7` provides no PSR17 factory yet, because that would have solved some part of this deps mess. /cc @Nyholm @sagikazarmark FYI
Note that https://packagist.org/providers/psr/http-factory-implementation lists `guzzle/psr7` but this is a wrong solution: no tagged release of it is PSR17-compatible, which means installing it doesn't solve the issue.

Commits
-------

96e70a4 [HttpClient] fix exception in case of PSR17 discovery failure
@fabpot fabpot changed the base branch from master to 4.4 January 7, 2020 19:20
@fabpot
Copy link
Member
fabpot commented Jan 7, 2020

Thank you @toooni.

fabpot added a commit that referenced this pull request Jan 7, 2020
This PR was submitted for the master branch but it was squashed and merged into the 4.4 branch instead (closes #35137).

Discussion
----------

[Messenger] Added check if json_encode succeeded

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

When trying to add a message to redis transport which can not be encoded with `json_encode` there is now a `TransportException` containing the `json_last_error_msg` as the message.
I had an issue where I tried to send an email through messenger by symfony mailer which contains a pdf attachment. Instead of an error while sending i got an error `Encoded envelope should have at least a "body"` which happened because the encoded message was `false`.

This is not exactly a bugfix, but IMO also not a feature worth being mentioned in the changelog so I am not sure I've filled out the Q/A correctly.

Commits
-------

a16a574 [Messenger] Added check if json_encode succeeded
@fabpot fabpot merged commit a16a574 into symfony:4.4 Jan 7, 2020
fabpot added a commit that referenced this pull request Jan 7, 2020
This PR was squashed before being merged into the 4.3 branch (closes #35150).

Discussion
----------

[Messenger] Added check if json_encode succeeded

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Similar PR as #35137 but for branch 4.3.

When trying to add a message to redis transport which can not be encoded with `json_encode` there is now a `TransportException` containing the `json_last_error_msg` as the message.
I had an issue where I tried to send an email through messenger by symfony mailer which contains a pdf attachment. Instead of an error while sending i got an error `Encoded envelope should have at least a "body"` which happened because the encoded message was `false`.

This is not exactly a bugfix, but IMO also not a feature worth being mentioned in the changelog so I am not sure I've filled out the Q/A correctly.

Commits
-------

c2bdc4c [Messenger] Added check if json_encode succeeded
symfony-splitter pushed a commit to symfony/messenger that referenced this pull request Jan 7, 2020
This PR was squashed before being merged into the 4.3 branch (closes #35150).

Discussion
----------

[Messenger] Added check if json_encode succeeded

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Similar PR as symfony/symfony#35137 but for branch 4.3.

When trying to add a message to redis transport which can not be encoded with `json_encode` there is now a `TransportException` containing the `json_last_error_msg` as the message.
I had an issue where I tried to send an email through messenger by symfony mailer which contains a pdf attachment. Instead of an error while sending i got an error `Encoded envelope should have at least a "body"` which happened because the encoded message was `false`.

This is not exactly a bugfix, but IMO also not a feature worth being mentioned in the changelog so I am not sure I've filled out the Q/A correctly.

Commits
-------

c2bdc4c4d3 [Messenger] Added check if json_encode succeeded
@toooni
Copy link
Contributor Author
toooni commented Jan 7, 2020

@fabpot @nicolas-grekas Thank you very much. Can I direct you to the issue which led me to this PR? #33920 (comment)

Right now the messenger aims to serialize the data in a readable format. This leads to issues with some transports (like redis, doctrine and probably SQS) because of the character encoding when having binary content. This is a problem especially if the mailer is used with an attachment (binary) through messenger.

I've fixed the issue by creating a SafeSerializer which encodes the data with base64 but I'd like to hear an opinion to what would be the best way to resolve this issue so I can try to create a proper PR.

@toooni toooni deleted the redis_transport_json_error branch January 7, 2020 19:32
This was referenced Jan 21, 2020
symfony-splitter pushed a commit to symfony/messenger that referenced this pull request Jan 28, 2020
This PR was squashed before being merged into the 4.3 branch (closes #35150).

Discussion
----------

[Messenger] Added ch
8717
eck if json_encode succeeded

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Similar PR as symfony/symfony#35137 but for branch 4.3.

When trying to add a message to redis transport which can not be encoded with `json_encode` there is now a `TransportException` containing the `json_last_error_msg` as the message.
I had an issue where I tried to send an email through messenger by symfony mailer which contains a pdf attachment. Instead of an error while sending i got an error `Encoded envelope should have at least a "body"` which happened because the encoded message was `false`.

This is not exactly a bugfix, but IMO also not a feature worth being mentioned in the changelog so I am not sure I've filled out the Q/A correctly.

Commits
-------

c2bdc4c4d3 [Messenger] Added check if json_encode succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0