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

[🐛 BUG]: marshal_payload: string field contains invalid UTF-8 #2104

Closed
1 task done
GityaMan opened this issue Jan 9, 2025 · 18 comments · Fixed by roadrunner-server/http#209
Closed
1 task done
Assignees
Labels
B-bug Bug: bug, exception
Milestone

Comments

@GityaMan
Copy link

GityaMan commented Jan 9, 2025

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Updating to 2024.1 breaks some http requests that worked previously.

Version (rr --version)

2024.1+ (protobuf)

How to reproduce the issue?

Send a request with some invalid data. For example, an invalid third-party cookie. We get 500 status code.

curl --request GET \
  --url http://localhost/ \
  --header 'Cookie: name=%A7 '

Relevant log output

No response

@rustatian
Copy link
Member

Hey @GityaMan 👋🏻

  1. Please, try to update to the latest (2024.3.x) version.
  2. Attach a relevant logs (debug).

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

I am using the latest version: 2024.3.1
rr version 2024.3.1 (build time: 2024-12-20T02:15:22+0000, go1.23.4), OS: linux, arch: amd64

@rustatian
Copy link
Member

Good, please, attach relevant debug logs as well and check that you use latest versions of the relevant php packages (worker, http, etc).
And last, but not least, what behavior did you expect?

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

{"L":"ERROR","T":"2025-01-09T06:59:21+0000","N":"http ","M":"payload forming error","start":"2025-01-09T06:59:21+0000","elapsed":0,"error":"marshal_payload: string field contains invalid UTF-8"}

{"L":"INFO","T":"2025-01-09T06:59:21+0000","N":"http ","M":"http log","status":500,"method":"GET","URI":"/buy-vsgradlutvhspacksbundleyearmac:1","URL":"/buy-vsgradlutvhspacksbundleyearmac:1","remote_address":"10.56.3.210:45184","read_bytes":0,"write_bytes":0,"start":"2025-01-09T06:59:21+0000","elapsed":0}

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

And last, but not least, what behavior did you expect?

I expect the behavior to be the same as before using protobuf, i.e. the request will be processed.

--
image
nginx / php-fpm request is also processed correctly.
In version 2023.3.12 the behavior is the same as in nginx/php-fpm

@rustatian
Copy link
Member

I'm not sure we should support non-utf-8 symbols. What is the use-case? UTF-8 nowadays is like 99.9% of used characters set.

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

Ignoring such data will work for me.
In the current situation, due to a third-party cookie of some analytical service, all my requests are broken.

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

The response code 400 is more appropriate for the current situation in my opinion.
But I would still like to process such requests.

@rustatian
Copy link
Member

Let me check how PHP is compatible with the string/bytes protobuf types (how they're represented in PHP). Because to support the non-utf-8 characters we need to send bytes to PHP, not strings.

@GityaMan
Copy link
Author

GityaMan commented Jan 9, 2025

https://github.com/protocolbuffers/protobuf/tree/main/php%2Fsrc%2FGoogle%2FProtobuf

There are several implementations of prootbuf in php, both in PHP and as extensions written in C. Need to check something specific?

@rustatian
Copy link
Member

Yeah, I know. Currently, cookies are represented as a hashmap in our protocol. As you may see, we use strings. Strings are UTF-8 only (this is why you see that error). To support non-utf-8 strings, cookies should be represented as bytes arrays. I guess (I'm not a PHP dev) that in PHP, there is no difference between these wire proto-types (how they're represented in PHP) and that won't require an update from the PHP side.

@GityaMan
Copy link
Author

Hey, @rustatian .
Can I expect such http requests to be supported in future versions? Or will more time be needed to investigate this issue?

@rustatian
Copy link
Member

Hey @GityaMan 👋🏻
I'll sync with the our PHP team today to double check the case I wrote above. If no BC should be introduced to fix that, then sure, I'll release a patch soon.

@rustatian
Copy link
Member

Ok, so, yeah, bytes/string is a single string type in PHP when compiled from protobuf.

@GityaMan
Copy link
Author

GityaMan commented Jan 17, 2025

{"L":"ERROR","T":"2025-01-17T02:49:18+0000","N":"http ","M":"execute","start":"2025-01-17T02:49:18+0000","elapsed":243,"error":"sync_worker_receive_frame: Network: EOF"} 2025-01-17T02:49:18.535892616Z {"L":"INFO","T":"2025-01-17T02:49:18+0000","N":"http ","M":"http log","status":500,"method":"GET","URI":"/","URL":"/","remote_address":"172.19.0.1:46906","read_bytes":0,"write_bytes":40,"start":"2025-01-17T02:49:18+0000","elapsed":243}
Now I get a different error but the response code is still the same - 500.

vendor/spiral/roadrunner-http/src/HttpWorker.php:71 $message->mergeFromString($payload->header) "Error occurred during parsing"
It seems that the DTO was not changed to "bytes" type.

@rustatian
Copy link
Member

DTO was changed, wait for the PHP part release.

@rustatian
Copy link
Member

You need to update composer deps, especially roadrunner-api-dto.

@GityaMan
Copy link
Author

Thank you, now everything works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-bug Bug: bug, exception
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants