@@ -20,14 +20,13 @@ pub struct ProfileOpts {
2020#[ folder = "providers/" ]
2121struct StandardProviders ;
2222
23- fn uses_msgpack_provider ( module : & Module ) -> bool {
23+ pub fn uses_msgpack_provider ( module : & Module ) -> bool {
2424 let imported_modules: HashSet < String > =
2525 module. imports ( ) . map ( |i| i. module ( ) . to_string ( ) ) . collect ( ) ;
2626
27- imported_modules. iter ( ) . any ( |name| {
28- name. starts_with ( "shopify_function_v" )
29- || ( name. starts_with ( "shopify_functions_javy_v" ) && name != "shopify_functions_javy_v1" )
30- } )
27+ imported_modules
28+ . iter ( )
29+ . any ( |name| name. starts_with ( "shopify_function_v" ) || name == "shopify_functions_javy_v2" )
3130}
3231
3332fn import_modules < T > (
@@ -139,13 +138,8 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
139138 let module = Module :: from_file ( & engine, & function_path)
140139 . map_err ( |e| anyhow ! ( "Couldn't load the Function {:?}: {}" , & function_path, e) ) ?;
141140
142- let uses_msgpack = uses_msgpack_provider ( & module) ;
143- let input_stream = if input. codec == Codec :: Messagepack || uses_msgpack {
144- let msgpack_bytes = rmp_serde:: to_vec ( & input. json_value . as_ref ( ) . unwrap ( ) ) ?;
145- MemoryInputPipe :: new ( msgpack_bytes)
146- } else {
147- MemoryInputPipe :: new ( input. raw . clone ( ) )
148- } ;
141+ // We now infer the codec in main.rs, so the input should already have the right format
142+ let input_stream = MemoryInputPipe :: new ( input. raw . clone ( ) ) ;
149143 let output_stream = MemoryOutputPipe :: new ( usize:: MAX ) ;
150144 let error_stream = MemoryOutputPipe :: new ( usize:: MAX ) ;
151145
@@ -220,18 +214,14 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
220214
221215 logs. extend_from_slice ( error_logs. as_bytes ( ) ) ;
222216
223- // When codec is not specified, we infer it from the input
224- let inferered_codec = if uses_msgpack {
225- Codec :: Messagepack
226- } else {
227- input. codec
228- } ;
217+ // The input codec is already inferred in main.rs, use it directly
218+ let output_codec = input. codec ;
229219 let raw_output = output_stream
230220 . try_into_inner ( )
231221 . expect ( "Output stream reference still exists" ) ;
232222 let output = BytesContainer :: new (
233223 BytesContainerType :: Output ,
234- inferered_codec ,
224+ output_codec ,
235225 raw_output. to_vec ( ) ,
236226 ) ?;
237227
0 commit comments