Adrian Witaszak
04/29/2024, 6:23 PMLambda.Http().invokeFunction<VehicleInfo>(
name = FunctionName.of(lambdaFunctionName),
req = Request(GET, "/data/$vin"),
autoMarshalling = configurableKotlinxSerialization,
)
One succeeds, other one gets error:
Serializer for class 'MemoryRequest' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
: kotlinx.serialization.SerializationException
kotlinx.serialization.SerializationException: Serializer for class 'MemoryRequest' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
creating lambda with
Lambda.Http()
and json:
val configurableKotlinxSerialization = ConfigurableKotlinxSerialization(
json = {
ignoreUnknownKeys = true
isLenient = false
prettyPrint = true
asConfigurable().withStandardMappings().done()
},
)
Andrew O'Hara
04/29/2024, 7:24 PMInvokeFunction
operation, passing in an http4k Request
as the payload, and overriding the marshaller from Moshi to kotlinx-serialization.
When you do this, you get a kotlinx-serialization error, because kotlinx serialization always requires serialization adapters to be generated at compile-time via the @Serializable
annotation and the appropriate gradle plugin. You almost certainly would not have had the opportunity to annotate the built-in Http4k Request
class. If you want to continue using kotlinx-serialization, you will need to come up with a DTO to encapsulate the Request
, and mark that with the annotation to generate the kotlinx serialization adapter.
You can likely get around this issue by continuing to use Moshi as is default, or perhaps even overriding with Jackson.Adrian Witaszak
04/29/2024, 7:30 PMreq
in invokeFunction
is type Any
, earlier i passed the Request and it did no like it, but i changed the Request to String and the error changed to actual failed response, which is progress.Andrew O'Hara
04/29/2024, 7:32 PM@Serializable
data class RequestDto(
val method: Method,
val uri: String,
val bodyBase64: String
)
Adrian Witaszak
04/29/2024, 7:34 PMAndrew O'Hara
04/29/2024, 7:36 PMAdrian Witaszak
04/29/2024, 7:39 PMAndrew O'Hara
04/29/2024, 7:44 PMRequest
as the payload is almost certainly not what you want to do here.Andrew O'Hara
04/29/2024, 7:47 PMAndrew O'Hara
04/29/2024, 7:51 PMJames Richardson
05/02/2024, 8:14 AM