Executing the lambda handler in all cases and only over-writing the error code if a valid parameter result is received means that the function code will be invoked and will falsely report an error instead of not being invoked and reporting a fake error.
|
if _fault_type == "status_code": |
|
result = func(*args, **kwargs) |
|
if isinstance(_chaos_conf.get("error_code"), int): |
|
_error_code = _chaos_conf.get("error_code") |
The simple solution would be to fix the order of operations. The structurally better solution would be to rebuild the whole library with a hooks pattern where the customer could define a list of faults/frequencies to inject before and after function execution.
Executing the lambda handler in all cases and only over-writing the error code if a valid parameter result is received means that the function code will be invoked and will falsely report an error instead of not being invoked and reporting a fake error.
aws-lambda-chaos-injection/chaos_lambda.py
Lines 343 to 346 in a6d10af
The simple solution would be to fix the order of operations. The structurally better solution would be to rebuild the whole library with a hooks pattern where the customer could define a list of faults/frequencies to inject before and after function execution.