7
7
8
8
from .boto3_proxy import SessionProxy , _get_boto_session
9
9
from .cipher import Cipher , KmsCipher
10
- from .exceptions import InternalFailure , InvalidRequest , _HandlerError
10
+ from .exceptions import (
11
+ AccessDenied ,
12
+ InternalFailure ,
13
+ InvalidRequest ,
14
+ _EncryptionError ,
15
+ _HandlerError ,
16
+ )
11
17
from .interface import (
12
18
BaseHookHandlerRequest ,
13
19
HandlerErrorCode ,
@@ -180,6 +186,9 @@ def _parse_request(
180
186
# credentials are used when rescheduling, so can't zero them out (for now)
181
187
invocation_point = HookInvocationPoint [event .actionInvocationPoint ]
182
188
callback_context = event .requestContext .callbackContext or {}
189
+ except _EncryptionError as e :
190
+ LOG .exception ("Failed to decrypt credentials" )
191
+ raise AccessDenied (f"{ e } ({ type (e ).__name__ } )" ) from e
183
192
except Exception as e :
184
193
LOG .exception ("Invalid request" )
185
194
raise InvalidRequest (f"{ e } ({ type (e ).__name__ } )" ) from e
@@ -228,7 +237,6 @@ def print_or_log(message: str) -> None:
228
237
print (message )
229
238
traceback .print_exc ()
230
239
231
- event : Optional [HookInvocationRequest ] = None
232
240
try :
233
241
sessions , invocation_point , callback , event = self ._parse_request (
234
242
event_data
@@ -276,12 +284,12 @@ def print_or_log(message: str) -> None:
276
284
# use the raw event_data as a last-ditch attempt to call back if the
277
285
# request is invalid
278
286
return self ._create_progress_response (
279
- progress , event
287
+ progress , event_data
280
288
)._serialize () # pylint: disable=protected-access
281
289
282
290
@staticmethod
283
291
def _create_progress_response (
284
- progress_event : ProgressEvent , request : Optional [HookInvocationRequest ]
292
+ progress_event : ProgressEvent , request : Optional [MutableMapping [ str , Any ] ]
285
293
) -> HookProgressEvent :
286
294
response = HookProgressEvent (Hook ._get_hook_status (progress_event .status ))
287
295
response .result = progress_event .result
@@ -291,7 +299,7 @@ def _create_progress_response(
291
299
response .callbackDelaySeconds = progress_event .callbackDelaySeconds
292
300
response .errorCode = progress_event .errorCode
293
301
if request :
294
- response .clientRequestToken = request .clientRequestToken
302
+ response .clientRequestToken = request .get ( " clientRequestToken" )
295
303
return response
296
304
297
305
@staticmethod
0 commit comments