boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.07k stars 1.87k forks source link

An error occurred when calling the PostText operation: Invalid Lambda Response #2301

Closed AlFalahTaieb closed 4 years ago

AlFalahTaieb commented 4 years ago

An error occurred (DependencyFailedException) when calling the PostText operation: Invalid Lambda Response: Received error response from Lambda: Unhandled

I'm testing a lambda function that is working like a charm in AWS lex Chat, but when doing my tests with boto it's throw me this error.

the text i post, will fulfill all my slots and return to me :

  "dialogState": "ConfirmIntent",
  "intentName": "Creation",
  "message": "Are you sure you want to create `alfalahtaieb` with email address `me@alfalahtaieb.com` displayed as `alfalahtaieb`?,
  "messageFormat": "PlainText",
  "responseAttributes": null,
  "responseCard": null,
  "sentimentResponse": null,
  "sessionAttributes": {
    "already_found": "true"
  },
  "sessionId": "2020-02-20T17:51:56.757Z-aQGEYZNl",
  "slotToElicit": null,
  "slots": {
    "name": "alfalahtaieb",
    "email": "me@alfalahtaieb.com",
    "nickname": "alfalahtaieb"
  }
}

Unfortunatly i got an error when testing with boto3 :/ couldn't find a way to bypass it. 
swetashre commented 4 years ago

@AlFalahTaieb - Thank you for your post. Can you please provide me the sample code so that i can reproduce the issue ? It would be helpful also if you can provide me debug log ? You can enable log by adding boto3.set_stream_logger('') to your code.

AlFalahTaieb commented 4 years ago

Hello @swetashre, here's the debug log:

2020-02-21 04:49:50,089 botocore.hooks [DEBUG] Event before-parameter-build.lex-runtime-service.PostText: calling handler <function generate_idempotent_uuid at 0x7fe67f5a4560>
2020-02-21 04:49:50,089 botocore.hooks [DEBUG] Event before-call.lex-runtime-service.PostText: calling handler <function inject_api_version_header_if_needed at 0x7fe67f5aa050>
2020-02-21 04:49:50,090 botocore.endpoint [DEBUG] Making request for OperationModel(name=PostText) with params: {'url_path': '/bot/bot_example/alias/default/user/W5AQErSi/text', 'query_string': {}, 'method': 'POST', 'headers': {'User-Agent': 'Boto3/1.10.38 Python/3.7.5 Linux/5.3.0-40-generic Botocore/1.13.38'}, 'body': b'{"inputText": "create user alfalahtaieb@me.com"}', 'url': 'https://runtime.lex.us-west-2.amazonaws.com/bot/bot_example/alias/default/user/W5AQErSi/text', 'context': {'client_region': 'us-west-2', 'client_config': <botocore.config.Config object at 0x7fe67efe3910>, 'has_streaming_input': False, 'auth_type': None}}
2020-02-21 04:49:50,090 botocore.hooks [DEBUG] Event request-created.lex-runtime-service.PostText: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fe67efe38d0>>
2020-02-21 04:49:50,090 botocore.hooks [DEBUG] Event choose-signer.lex-runtime-service.PostText: calling handler <function set_operation_specific_signer at 0x7fe67f629a70>
2020-02-21 04:49:50,090 botocore.auth [DEBUG] Calculating signature using v4 auth.
2020-02-21 04:49:50,090 botocore.auth [DEBUG] CanonicalRequest:
POST
/bot/bot_example/alias/default/user/W5AQErSi/text

host:runtime.lex.us-west-2.amazonaws.com
x-amz-date:20200221T034950Z

host;x-amz-date
406a7ab113d9f706fd2f245b1203e8d1943f379a05c022d561aaa042f1ca209b
2020-02-21 04:49:50,090 botocore.auth [DEBUG] StringToSign:
AWS4-HMAC-SHA256
20200221T034950Z
20200221/us-west-2/lex/aws4_request
f4a577d645e478a8a311ec685d5145b1eddef2352b03f4d0bcd528e37d2f80e6
2020-02-21 04:49:50,090 botocore.auth [DEBUG] Signature:
77e1636aedf9188e9def0011d354e2fda689b2a9279dab395e72a4f169bb446c
2020-02-21 04:49:50,090 botocore.endpoint [DEBUG] Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://runtime.lex.us-west-2.amazonaws.com/bot/bot_example/alias/default/user/W5AQErSi/text, headers={'User-Agent': b'Boto3/1.10.38 Python/3.7.5 Linux/5.3.0-40-generic Botocore/1.13.38', 'X-Amz-Date': b'20200221T034950Z', 'Authorization': b'AWS4-HMAC-SHA256 Credential=AKIAWITO6DBUJ2EHS4OD/20200221/us-west-2/lex/aws4_request, SignedHeaders=host;x-amz-date, Signature=77e1636aedf9188e9def0011d354e2fda689b2a9279dab395e72a4f169bb446c', 'Content-Length': '53'}>
2020-02-21 04:49:50,091 urllib3.connectionpool [DEBUG] Starting new HTTPS connection (1): runtime.lex.us-west-2.amazonaws.com:443
2020-02-21 04:49:51,057 urllib3.connectionpool [DEBUG] https://runtime.lex.us-west-2.amazonaws.com:443 "POST /bot/bot_example/alias/default/user/W5AQErSi/text HTTP/1.1" 424 85
2020-02-21 04:49:51,058 botocore.parsers [DEBUG] Response headers: {'Content-Type': 'application/json', 'Date': 'Fri, 21 Feb 2020 03:49:50 GMT', 'x-amzn-ErrorType': 'DependencyFailedException:http://internal.amazon.com/coral/com.amazonaws.deepsense.runtimeservice/', 'x-amzn-RequestId': '29524e21-8d55-43fe-9668-be48328c2408', 'Content-Length': '85', 'Connection': 'keep-alive'}
2020-02-21 04:49:51,059 botocore.parsers [DEBUG] Response body:
b'{"Message":"Invalid Lambda Response: Received error response from Lambda: Unhandled"}'
2020-02-21 04:49:51,060 botocore.hooks [DEBUG] Event needs-retry.lex-runtime-service.PostText: calling handler <botocore.retryhandler.RetryHandler object at 0x7fe67efe3c90>
2020-02-21 04:49:51,060 botocore.retryhandler [DEBUG] No retry needed.
Traceback (most recent call last):
  File "lexTesting.py", line 330, in <module>
    print(LexTest.test_lex_dialog('Add a user in Jira alfalahtaieb@me.com','bot_example'))
  File "lexTesting.py", line 205, in test_lex_dialog
    inputText=inputText    # Input the user message
  File "/home/taieb/.local/lib/python3.7/site-packages/botocore/client.py", line 272, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/taieb/.local/lib/python3.7/site-packages/botocore/client.py", line 576, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.DependencyFailedException: An error occurred (DependencyFailedException) when calling the PostText operation: Invalid Lambda Response: Received error response from Lambda: Unhandled
swetashre commented 4 years ago

As this error is coming from service, i have already contacted the service team. I will post here when i get any update.

phani-srikar commented 4 years ago

Any update on this issue? I am facing the same error When the slots are filled and intent is to be fulfilled, it throws this error instead. It works on node.js sdk.

swetashre commented 4 years ago

We would need some account specific information in order to debug the issue. So i would recommend reaching out to AWS Support.