Error message of "Malformed UTF-8" hiding real error messages
See original GitHub issueAPI Platform version(s) affected: v2.6.5
Description
I’m getting this error for most problems on api calls:
For this request data:
{
"order": "api/orders/696e4882-88bf-4b91-984c-ec41f7498958",
"token": "12345",
"cardNumber": "xyz",
"cardExpiryDate": "1125",
"currency": "CHF",
"cardSchemeName": "Visa",
"dataProcessed": "2021-08-25T10:14:32.534Z",
"rawResponse": "data",
"createdAt": "2021-08-25T10:14:32.534Z",
"uuid": "3fa85f64-5717-4562-b3fc-2c963f66af79"
}
The issue here is dataProcessed
was renamed to the correct naming of dateProcessed
(note the e), but because of, (I’m assuming) the usage of a uuid, there were encoding issues on the exception and that naming issue was hidden, and I could only see it in the logs:
[2021-08-27T20:34:54.262360+00:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\NotNullConstraintViolationException: "An exception occurred while executing 'INSERT INTO payment (token, card_number, card_expiry_date, currency, card_scheme_name, date_processed, raw_response, created_at, updated_at, uuid, order_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["12345", "xyz", "1125", "CHF", "Visa", null, "data", "2021-08-27 20:34:54", "2021-08-27 20:34:54", "\x3f\xa8\x5f\x64\x57\x17\x45\x62\xb3\xfc\x2c\x96\x3f\x66\xaf\x79", 1]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'date_processed' cannot be null"....
This is causing HUGE issues as every little error will give me the Malformed UTF-8...
error message and I have to go into the server and tail the logs o see the actual error.
HELP!
How to reproduce
Have something throw an error where you use uuids
Possible Solution
Additional Context
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
'Malformed UTF-8 characters, possibly incorrectly encoded' in ...
In the data result there are some fields encoded in UTF-8 . The following statement return JsonResponse::create($data);. returns the error below
Read more >A quick tale about FEFF, an invisible UTF-8 character that ...
If you do ever encounter an error like that, be sure to look for hidden characters not shown by your editor. If you...
Read more >Solved: Invalid UTF-8 start byte 0xa0 - SmartBear Community
Solved: I am not able to fix the below issue in ReadyAPI - Invalid UTF-8 start byte 0xa0. Getting this error message in...
Read more >Haskell with UTF-8 - Serokell
Unfortunately, sometimes the solutions are not well-thought-out, such as this fix to a real problem affecting everyone, bashfully hidden behind ...
Read more >A client is getting an error: “Invalid byte sequence for encoding ...
The error messages: "Invalid byte sequence for encoding "UTF8": 0x00" signifies that probably a NULL value was inserted into Database.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Related https://github.com/api-platform/api-platform/issues/1900#issuecomment-883489939
@dunglas A solution is offered here: https://github.com/api-platform/api-platform/issues/1900 and it’s just he addition of one more flag:
JSON_INVALID_UTF8_IGNORE