boto / boto3

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

validate_e911_address returns invalid country code #4216

Closed cjhelloletsgo closed 2 months ago

cjhelloletsgo commented 2 months ago

Describe the bug

The validate_e911_address api returns invalid country codes. If I enter "US" for the country code like in this python script (Address is a random address off zillow)

import boto3

chime_sdk_voice_client = boto3.client("chime-sdk-voice")

chime_response = chime_sdk_voice_client.validate_e911_address(
    AwsAccountId="YOUR_ACCOUNT_ID_GOES_HERE",
    StreetNumber="4360",
    StreetInfo="E 16th Avenue Unit 3",
    City="Denver",
    State="CO",
    Country="US",
    PostalCode="80220",
)

print(f"chime_response: {chime_response}")

I get this response:

{
  "ResponseMetadata": {
    "RequestId": "2043dd77-b139-4990-9ff9-13e89d969be6",
    "HTTPStatusCode": 202,
    "HTTPHeaders": {
      "date": "Tue, 23 Jul 2024 00:46:58 GMT",
      "content-type": "application/json",
      "content-length": "239",
      "connection": "keep-alive",
      "x-amzn-requestid": "2043dd77-b139-4990-9ff9-13e89d969be6"
    },
    "RetryAttempts": 0
  },
  "ValidationResult": 1,
  "AddressExternalId": "726bccfb130b49fba7b017aa8fcf96f7",
  "Address": {
    "streetName": "16th",
    "streetSuffix": "Ave",
    "preDirectional": "E",
    "streetNumber": "4360",
    "city": "Denver",
    "state": "CO",
    "postalCode": "80220",
    "country": "USA"
  }
}

ValidationResult is 1, which means the address had to be modified, the Country was returned as "USA" instead of "US" like I passed it in.

But if I try to validate again with USA instead this time it errors out and says that is invalid

Traceback (most recent call last):
  File "/home/colton/projects/work/firstfire/agero/test.py", line 5, in <module>
    chime_response = chime_sdk_voice_client.validate_e911_address(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/colton/projects/work/firstfire/agero/.venv/lib/python3.12/site-packages/botocore/client.py", line 565, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/colton/projects/work/firstfire/agero/.venv/lib/python3.12/site-packages/botocore/client.py", line 1021, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the ValidateE911Address operation: 2 validation errors detected: Value at 'country' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[A-Z]{2,2}$; Value at 'country' failed to satisfy constraint: Member must have length less than or equal to 2

The documentation is also unclear how to handle apartment numbers or different units, as you can see it just removes it in the validation result but it seems like it should be returned as postDirectional looking through the api responses.

Link to api docs

Expected Behavior

The api validates the address, if changes are required it returns a valid address in the response

Current Behavior

invalid responses are returned/apartments are unable to be accounted for in emergency calls

Reproduction Steps

Use snippets above

Possible Solution

Fix bugs/Improve documentation

Additional Information/Context

No response

SDK version used

1.34.145

Environment details (OS name and version, etc.)

Ubuntu 24.04

tim-finnigan commented 2 months ago

Thanks for reaching out. The validate_e911_address command makes a call to the ValidateE911Address API. We reached out to the Chime team regarding this behavior and can let you know when we have an update.

Since this is an issue involving the API, which is used across SDKs, I created a new issue to track this in our cross-SDK repository: https://github.com/aws/aws-sdk/issues/789. Please refer to that issue for updates going forward.

github-actions[bot] commented 2 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.