boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.49k stars 1.09k forks source link

lex-model responseCard is not required, but also must be a minimum length #1701

Closed rtkkroland closed 5 years ago

rtkkroland commented 5 years ago

Reproduction

Send the following to put_bot() lex-model client:

{
  u'description': u'Lex test', 
  u'locale': u'en-US',
  u'processBehavior': u'BUILD',
  u'abortStatement': {
    u'messages': [
      {u'content': u'I do not understand. Sorry. Good-bye.', u'contentType': u'PlainText', u'groupNumber': u'1'}
    ]
  }, 
  u'createVersion': u'false', 
  u'childDirected': u'false', 
  u'clarificationPrompt': {
    u'maxAttempts': u'5',
     u'messages': [
      {u'content': u"I'm sorry, I didn't get that.", u'contentType': u'PlainText', u'groupNumber': u'1'}, 
      {u'content': u"I'm just a bot, I didn't understand ...", u'contentType': u'PlainText', u'groupNumber': u'1'}
    ]
  }, 
  u'voiceId': u'Kendra', 
  u'idleSessionTTLInSeconds': u'60', 
  u'name': u'MyLexBot'
}

The following error is generated:

File "/var/task/botocore/validate.py", line 297, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
ParamValidationError: Parameter validation failed:
Invalid length for parameter abortStatement.responseCard, value: 0, valid range: 1-inf
Invalid length for parameter clarificationPrompt.responseCard, value: 0, valid range: 1-inf

The documentation https://docs.aws.amazon.com/lex/latest/dg/API_Prompt.html#lex-Type-Prompt-responseCard says the responseCard is not required (and is not in the json), yet it still fails because it is 0 length.

If it must be length 1, then it should be marked as required.

Adding responseCard: '' to confirmationPrompt and abortStatement causes the exact same error (now expected since included but 0 length).

Adding responseCard: 'This is the response card' allows the put_bot to succeed.

JordonPhillips commented 5 years ago

What version of botocore are you using? I'm not able to replicate with the latest version.

rtkkroland commented 5 years ago

This is running inside a Lambda in AWS, Python 2.7 with just a "import boto3"

JordonPhillips commented 5 years ago

I would highly recommend vending your own copy of botocore along with your deployment package so you can control the version. Is your environment modified in any way or are you using a blank template? The version in lambda right now should be fine, but you could have an old model hanging around in ~/.aws/models or wherever you have the AWS_DATA_PATH configured.

rtkkroland commented 5 years ago

It's pulling from S3 and you are correct, I am including my own boto3: 1.9.92

stealthycoin commented 5 years ago

Closing out old issues that are likely resolved now that the closing soon bot has been added. Let us know if updating this did not fix it for you, I suspect that it would.