Repository: alexa/alexa-skills-kit-sdk-for-python

Issue:
Regression in GlobalResponseInterceptor - unexpected keyword argument 'dispatch_output'

<!-- Check one of the following options with "x" -->
<pre><code>
[X] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
</code></pre>

<!--- Provide a general summary of the issue in the Title above -->
With the recent update to 1.10 and any resultant changes in the backend - a regression was introduced by the Alexa Skills Kit involving the usage of decorated @SkillBuilder.global_response_interceptor(). Attempting to implement a response interceptor will result in an exception during runtime: `<lambda>() got an unexpected keyword argument 'dispatch_output'`

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
I shouldn't have to comment out my response logging code. Especially from a core functional platform defect introduced as a regression.

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- Include full errors, uncaught exceptions, stack traces, and relevant logs -->
<!--- If service responses are relevant, please include any -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
It fails with the following error:

[ERROR]	2019-05-30T00:46:47.187Z	0c4a841e-0ad3-4c66-bb6e-96d4726c2d38	<lambda>() got an unexpected keyword argument 'dispatch_output'
Traceback (most recent call last):
File "/opt/python/ask_sdk_runtime/dispatch.py", line 122, in dispatch
handler_input=handler_input, dispatch_output=output)
TypeError: <lambda>() got an unexpected keyword argument 'dispatch_output'
[DEBUG]	2019-05-30T00:46:47.229Z	0c4a841e-0ad3-4c66-bb6e-96d4726c2d38	get_prompt for exception: There was a problem on our end and we have recorded the issue. Please try again.

## Possible Solution
```
// Not required, but suggest a fix/reason for the bug,
// or ideas how to implement the addition or change
```
Commenting out any usage of global_response_interceptor will fix it but you lose response interception.

## Steps to Reproduce (for bugs)
```
// Provide a self-contained, concise snippet of code
// For more complex issues provide a repo with the smallest sample that reproduces the bug
// Including business logic or unrelated code makes diagnosis more difficult
```
1. Configure a custom skill.
2. Using the following Python code as a the lambda handler and including the 1.10 or 1.9 ASK SDK will reproduce the issue when attempting to launch the skill.

```
from ask_sdk_core.skill_builder import SkillBuilder
from ask_sdk_core.utils import is_request_type

sb = SkillBuilder()


@sb.exception_handler(can_handle_func=lambda i, e: True)
def all_exception_handler(handler_input, exception):
    print(exception)
    return handler_input \
        .response_builder \
        .speak('Exception') \
        .set_should_end_session(True) \
        .response


@sb.request_handler(can_handle_func=is_request_type('LaunchRequest'))
def launch_request_handler(handler_input):
    return handler_input \
        .response_builder \
        .speak('Launch Request') \
        .set_should_end_session(False) \
        .response


@sb.global_request_interceptor()
def request_logger(handler_input):
    print('request', handler_input.request_envelope)


@sb.global_response_interceptor()
def response_logger(handler_input, response):
    print('response', handler_input.request_envelope)
    if response is not None:
        print(response)


handler = sb.lambda_handler()
```

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
This was a regression, the code was working then it was not.

## Your Environment
<!--- Include as many relevant details about the environment where the bug was discovered -->
* ASK SDK for Python used: x.x.x
1.9 and 1.10 were tested.
* Operating System and version:
Lambda

## Python version info
* Python version used for development:
Python 3.7


Comments:

Patch:
diff --git a/ask-sdk-runtime/ask_sdk_runtime/dispatch.py b/ask-sdk-runtime/ask_sdk_runtime/dispatch.py
index 855f563..3fbf63f 100644
--- a/ask-sdk-runtime/ask_sdk_runtime/dispatch.py
+++ b/ask-sdk-runtime/ask_sdk_runtime/dispatch.py
@@ -119,7 +119,7 @@ class GenericRequestDispatcher(AbstractRequestDispatcher):
 
             for response_interceptor in self.response_interceptors:
                 response_interceptor.process(
-                    handler_input=handler_input, dispatch_output=output)
+                    handler_input=handler_input, response=output)
 
             return output
         except Exception as e:
@@ -186,6 +186,6 @@ class GenericRequestDispatcher(AbstractRequestDispatcher):
             request_handler_chain.response_interceptors)
         for response_interceptor in local_response_interceptors:
             response_interceptor.process(
-                handler_input=handler_input, dispatch_output=output)
+                handler_input=handler_input, response=output)
 
         return output
diff --git a/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py b/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py
index 96da21b..d74b53f 100644
--- a/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py
+++ b/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py
@@ -97,16 +97,16 @@ class AbstractResponseInterceptor(object):
     __metaclass__ = ABCMeta
 
     @abstractmethod
-    def process(self, handler_input, dispatch_output):
+    def process(self, handler_input, response):
         # type: (Input, Output) -> None
         """Process the input and the output after the Handler is run.
 
         :param handler_input: Generic input passed to the
             dispatcher.
         :type handler_input: Input
-        :param dispatch_output: Execution result of the Handler on
+        :param response: Execution result of the Handler on
             dispatch input.
-        :type dispatch_output: Union[None, Output]
+        :type response: Union[None, Output]
         :rtype: None
         """
         raise NotImplementedError


Test patch:
diff --git a/ask-sdk-runtime/tests/unit/test_dispatch.py b/ask-sdk-runtime/tests/unit/test_dispatch.py
index 825c645..a7a52a1 100644
--- a/ask-sdk-runtime/tests/unit/test_dispatch.py
+++ b/ask-sdk-runtime/tests/unit/test_dispatch.py
@@ -301,14 +301,14 @@ class TestRequestDispatcher(unittest.TestCase):
 
         test_interceptor_1.process.assert_called_once_with(
             handler_input=self.valid_handler_input,
-            dispatch_output=test_response_before_interceptor), (
+            response=test_response_before_interceptor), (
             "Dispatcher dispatch method didn't process local response "
             "interceptors after calling request handler "
             "handle")
 
         test_interceptor_2.process.assert_called_once_with(
             handler_input=self.valid_handler_input,
-            dispatch_output=test_response_from_interceptor_1), (
+            response=test_response_from_interceptor_1), (
             "Dispatcher dispatch method didn't process local response "
             "interceptors after calling request handler "
             "handle")
@@ -350,13 +350,13 @@ class TestRequestDispatcher(unittest.TestCase):
 
         test_interceptor_1.process.assert_called_once_with(
             handler_input=self.valid_handler_input,
-            dispatch_output=test_response_before_interceptor), (
+            response=test_response_before_interceptor), (
             "Dispatcher dispatch method didn't process global request "
             "interceptors after calling dispatch request")
 
         test_interceptor_2.process.assert_called_once_with(
             handler_input=self.valid_handler_input,
-            dispatch_output=test_response_from_interceptor_1), (
+            response=test_response_from_interceptor_1), (
             "Dispatcher dispatch method didn't process global request "
             "interceptors after calling dispatch request")