File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 33
44from onepassword .errors import raise_typed_exception
55
6+ # In empirical tests, we determined that maximum message size that can cross the FFI boundary
7+ # is ~128MB. Past this limit, FFI will throw an error and the program will crash.
8+ # We set the limit to 50MB to be safe and consistent with the other SDKs, to be reconsidered upon further testing
9+ MESSAGE_LIMIT = 50 * 1024 * 1024 ;
610
711machine_arch = platform .machine ().lower ()
812
@@ -26,16 +30,24 @@ async def _init_client(client_config):
2630
2731# Invoke calls specified business logic from the SDK core.
2832async def _invoke (invoke_config ):
33+ serialized_config = json .dumps (invoke_config )
34+ if len (serialized_config ) > MESSAGE_LIMIT :
35+ raise ValueError (
36+ f"Message size exceeds the limit of { MESSAGE_LIMIT } bytes." )
2937 try :
30- return await core .invoke (json . dumps ( invoke_config ) )
38+ return await core .invoke (serialized_config )
3139 except Exception as e :
3240 raise_typed_exception (e )
3341
3442
3543# Invoke calls specified business logic from the SDK core.
3644def _invoke_sync (invoke_config ):
45+ serialized_config = json .dumps (invoke_config )
46+ if len (serialized_config ) > MESSAGE_LIMIT :
47+ raise ValueError (
48+ f"Message size exceeds the limit of { MESSAGE_LIMIT } bytes." )
3749 try :
38- return core .invoke_sync (json . dumps ( invoke_config ) )
50+ return core .invoke_sync (serialized_config )
3951 except Exception as e :
4052 raise_typed_exception (e )
4153
You can’t perform that action at this time.
0 commit comments