You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server needs to be more robust to malformed requests #1930
I get the following errors randomly, which I assume are due to people portscanning the Internet and sending garbage to open ports to see what happens:
2024-02-18 06:49:03.355504Z Internal server error. Failed to read body of request.FormatException: Unexpected extension byte (at offset 1)#0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1741:7)convert_patch.dart:1741#1 Utf8Decoder.convert (dart:convert/utf.dart:349:37)utf.dart:349#2 Server._readBody (package:serverpod/src/server/server.dart:350:32)server.dart:350<asynchronous suspension>#3 Server._handleRequest (package:serverpod/src/server/server.dart:270:16)server.dart:270<asynchronous suspension>
The code in question is the last line of _readBody:
Future<String?> _readBody(HttpRequest request) async {
// TODO: Find more efficient solution?var len =0;
var data =<int>[];
awaitfor (var segment in request) {
len += segment.length;
if (len > serverpod.config.maxRequestSize) returnnull;
data += segment;
}
returnconstUtf8Decoder().convert(data);
}
This really needs a try/catch around it, so that requests with invalid Utf8 result in a 400 result code, rather than just throwing an exception on the server (which presumably sends back a 500 result code).
There may be other parts of request handling that also decode Utf8, and should be similarly handled -- I haven't checked.
Reacted by Alexander Sandor, Isak, Mohamed Gamal, Bin Emmanuel, Ashish , Guillermo Rojo, Jason Downs and Ellet
I've been getting this a lot too with my newly deployed server, which is now on Serverpod v3 with the handling done by Relic. Logs show the following error multiple times:
As @lukehutch said, this seems to be from people spamming stuff, or webcrawlers etc. because all the timestamps are from when I was sleeping, and it's on a new site that no one knows about yet.
Activity
jason-downs commentedon Feb 3, 2026
I've been getting this a lot too with my newly deployed server, which is now on Serverpod v3 with the handling done by Relic. Logs show the following error multiple times:
As @lukehutch said, this seems to be from people spamming stuff, or webcrawlers etc. because all the timestamps are from when I was sleeping, and it's on a new site that no one knows about yet.