alexa-skills-kit-sdk-for-python icon indicating copy to clipboard operation
alexa-skills-kit-sdk-for-python copied to clipboard

ENDPOINT_TIMEOUT is not handled properly in Incorrect handling of SessionEndedRequest.

Open mansisorathiya opened this issue 1 year ago • 0 comments

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected Behavior

ENDPOINT TIMEOUT error should parse correctly.

if lambda(backend) takes too long to respond (> 50 seconds), Alexa will say "The requested skill took too long to respond" and send a SessionEndedRequest request to your skill with the error type set to ENDPOINT_TIMEOUT i.e:

{
	"version": "1.0",
	"session": {
		...
	},
	"context": {
		...
	},
	"request": {
		"type": "SessionEndedRequest",
		"requestId": "...",
		"timestamp": "...",
		"locale": "en-GB",
		"reason": "ERROR",
		"error": {
			"type": "ENDPOINT_TIMEOUT",
			"message": "An exception occurred while dispatching the request to the skill."
		}
	}
}

See alexa documentation of SessionEndedRequest which clearly mentions ENDPOINT_TIMEOUT as one of the possible types.

Current Behavior

Instead of this request being handled by the handler for SessionEndedRequest requests, the serializer.deserialize call to create a RequestEnvelope object will throw an error: SerializationException: ENDPOINT_TIMEOUT is not a valid SessionEndedErrorType.

Stack trace below


[ERROR] SerializationException: 'ENDPOINT_TIMEOUT' is not a valid SessionEndedErrorTypeTraceback (most recent call last):  File "/opt/python/ask_sdk_core/skill_builder.py", line 95, in wrapper    request_envelope = skill.serializer.deserialize(  File "/opt/python/ask_sdk_core/serialize.py", line 133, in deserialize    return self.__deserialize(payload, obj_type)  File "/opt/python/ask_sdk_core/serialize.py", line 194, in __deserialize    return self.__deserialize_model(payload, obj_type)  File "/opt/python/ask_sdk_core/serialize.py", line 312, in __deserialize_model    raise SerializationException(str(e)) | [ERROR] SerializationException: 'ENDPOINT_TIMEOUT' is not a valid SessionEndedErrorType Traceback (most recent call last):   File "/opt/python/ask_sdk_core/skill_builder.py", line 95, in wrapper     request_envelope = skill.serializer.deserialize(   File "/opt/python/ask_sdk_core/serialize.py", line 133, in deserialize     return self.__deserialize(payload, obj_type)   File "/opt/python/ask_sdk_core/serialize.py", line 194, in __deserialize     return self.__deserialize_model(payload, obj_type)   File "/opt/python/ask_sdk_core/serialize.py", line 312, in __deserialize_model     raise SerializationException(str(e))
-- | --

Steps to Reproduce (for bugs)

1. Configure custom lambda which is not hosted by alexa
2. Make sure lambda timeout configured is more than 60 seconds
3. Use  `time.sleep(60)` code to artificially introduce delay of 60 seconds.
4. Try invoking skill intent which hits code referenced in #3

Context

Logging what caused session to end for deep dive later.

Your Environment

  • ASK SDK for Python used: 3.9
  • Operating System and version: Lambda

Python version info

  • Python version used for development: 3.9

Similar issue got closed before : #64

mansisorathiya avatar Sep 21 '22 07:09 mansisorathiya