Commit f3cadf1
committed
[Messenger] Sanitize binary strings in FlattenException trace args before normalizing
When an exception is thrown over a call frame whose argument contains
non-UTF-8 bytes (e.g. a PDF body passed to a handler), the FlattenException
captures the raw byte sequence in its trace. Encoding the resulting
ErrorDetailsStamp through the JSON serializer then fails with
NotEncodableValueException("Malformed UTF-8 characters, possibly
incorrectly encoded"), so the message never reaches the failure
transport for retry/inspection.
Replace any non-UTF-8 string argument (recursively, including arrays of
args) with a '(binary string)' placeholder during normalize(). The
denormalizer is unchanged: the round trip is intentionally lossy for
binary blobs that are only meaningful for diagnostics anyway.
Direction was endorsed by @nicolas-grekas in #57535: the cleanup
belongs in FlattenExceptionNormalizer, not in FlattenException itself,
because FlattenException makes no UTF-8 promise.1 parent d3c1e02 commit f3cadf1Copy full SHA for f3cadf1
2 files changed
+76-1Lines changed: 76 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Symfony/Component/Messenger
- Tests/Transport/Serialization/Normalizer
- Transport/Serialization/Normalizer
Expand file treeCollapse file tree
Open diff view settings
Collapse file
src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php+47Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
69 | 69 | |
70 | 70 | |
71 | 71 | |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
72 | 119 | |
73 | 120 | |
74 | 121 | |
|
Collapse file
src/Symfony/Component/Messenger/Transport/Serialization/Normalizer/FlattenExceptionNormalizer.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/Serialization/Normalizer/FlattenExceptionNormalizer.php+29-1Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | | - |
| 41 | + |
42 | 42 | |
43 | 43 | |
44 | 44 | |
| ||
87 | 87 | |
88 | 88 | |
89 | 89 | |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
90 | 118 | |
0 commit comments