Repository navigation
Closed
Labels
Description
Describe the bug
When return type of an endpoint function is a record, deserialization logic iniside generated test utilities breaks, and tries to deserialize-already-deserialized objects:
// greeting_endpoint.dart
Future<(Greeting, String)> hello(Session session, String name) async {
return (
Greeting(
message: 'Hello $name',
author: 'Serverpod',
timestamp: DateTime.now(),
),
name
);
}withServerpod('Given Greeting endpoint', (sessionBuilder, endpoints) {
test(
'when calling `hello` with name then returned greeting includes name',
() async {
// Call the endpoint method by using the `endpoints` parameter and
// pass `sessionBuilder` as a first argument. Refer to the docs on
// how to use the `sessionBuilder` to set up different test scenarios.
final greeting = await endpoints.greeting.hello(sessionBuilder, 'Bob');
expect(greeting.$1.message, 'Hello Bob');
},
);
});Server default listening on port 8080
package:serverpod_records_test_server/src/generated/protocol.dart 37:36 Protocol.deserialize
package:serverpod_records_test_server/src/generated/protocol.dart 44:9 Protocol.deserialize
test/integration/test_tools/serverpod_test_tools.dart 135:32 _GreetingEndpoint.hello.<fn>.<fn>
===== asynchronous gap ===========================
test/integration/test_tools/serverpod_test_tools.dart 129:33 _GreetingEndpoint.hello.<fn>
===== asynchronous gap ===========================
package:serverpod_test/src/function_call_wrappers.dart 12:12 callAwaitableFunctionAndHandleExceptions
===== asynchronous gap ===========================
test/integration/greeting_endpoint_test.dart 19:26 main.<fn>.<fn>
type '_GreetingImpl' is not a subtype of type 'Map<String, dynamic>'
For some reason, stuff inside to-deserialize map that represents a record, is, already, deserialized
Then, it tries to deserialize them individually:
...but it already is:
...and it's not a Map
To reproduce
I created a sample project with Serverpod Mini - just git pull https://github.com/TheLastGimbus/serverpod_records_test, and run dart test inside server
Expected behavior
It should work -_-
Library version
2.9.1
Platform information
Well, Linux, but i doubt it matters
Additional context
Maybe I have a same problem as #3840
How experienced are you with this library?
Intermediate - Familiar with the basics or have used it in a few projects
Are you interested in working on a PR for this?
- I want to work on this
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 🚀
Activity
TheLastGimbus commentedon Oct 31, 2025
Okay, I did this
And it works 🎉
I'm not brave to say that I understand all of this generator black magic, but I guess someone forgot it and it can just be added
I found proper place in the generator and "fixed" it - works for me for now 🎉
Will drop a PR soon
SandPod commentedon Nov 6, 2025
@TheLastGimbus Thank you for taking on fixing this!
The PR is currently not passing our CI pipeline. Give me a ping once it is green for review.