Skip to content

Remove hardcoded US country code#19

Merged
mcrundo merged 1 commit into
mainfrom
fix-country-default
Apr 16, 2026
Merged

Remove hardcoded US country code#19
mcrundo merged 1 commit into
mainfrom
fix-country-default

Conversation

@mcrundo
Copy link
Copy Markdown
Owner

@mcrundo mcrundo commented Apr 16, 2026

Changes in src/address_validation/models.py:

  • Line 15: Changed country: str = "US" → country: str = "" (dataclass default)
  • Line 52: Changed data.get("country", "US") → data.get("country", "") (parsing default)

Changes in tests/test_models.py:

  • Updated test_from_dict_lines_only to assert country == "" instead of "US"
  • Updated test_to_google_request_minimal to expect no regionCode key when country isn't provided

Now when a caller omits country, the request to Google won't include a regionCode at all — letting
Google infer the country from the address itself. When a caller explicitly passes "country": "UK", it'll
be sent correctly as regionCode: "UK".

@github-actions
Copy link
Copy Markdown

Terraform Plan 📖success

Show Plan
aws_secretsmanager_secret.google_maps_api_key: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:023179631616:secret:address-validation/dev/google-maps-api-key]
data.aws_iam_policy_document.lambda_assume_role: Reading...
aws_apigatewayv2_api.this: Refreshing state... [id=py1sucuxvi]
aws_sqs_queue.handler_dlq: Refreshing state... [id=https://sqs.us-east-2.amazonaws.com/023179631616/address-validation-handler-dlq-dev]
aws_cloudwatch_log_group.health: Refreshing state... [id=/aws/lambda/address-validation-health-dev]
aws_secretsmanager_secret.api_key: Refreshing state... [id=arn:aws:secretsmanager:us-east-2:023179631616:secret:address-validation/dev/api-key]
aws_cloudwatch_log_group.api_gateway: Refreshing state... [id=/aws/apigateway/address-validation-dev]
data.aws_iam_policy_document.lambda_assume_role: Read complete after 0s [id=2690255455]
aws_cloudwatch_log_group.handler: Refreshing state... [id=/aws/lambda/address-validation-handler-dev]
aws_cloudwatch_log_group.authorizer: Refreshing state... [id=/aws/lambda/address-validation-authorizer-dev]
aws_iam_role.lambda_exec: Refreshing state... [id=address-validation-lambda-dev]
data.aws_iam_policy_document.secrets_read: Reading...
data.aws_iam_policy_document.authorizer_secrets: Reading...
data.aws_iam_policy_document.secrets_read: Read complete after 0s [id=3213121637]
data.aws_iam_policy_document.authorizer_secrets: Read complete after 0s [id=2856189735]
data.aws_iam_policy_document.lambda_logs: Reading...
aws_apigatewayv2_stage.default: Refreshing state... [id=$default]
data.aws_iam_policy_document.lambda_logs: Read complete after 0s [id=543498868]
data.aws_iam_policy_document.dlq_send: Reading...
aws_cloudwatch_metric_alarm.dlq_depth: Refreshing state... [id=address-validation-dlq-depth-dev]
data.aws_iam_policy_document.dlq_send: Read complete after 0s [id=1518684834]
aws_iam_role_policy.authorizer_secrets: Refreshing state... [id=address-validation-lambda-dev:authorizer-secrets-read]
aws_iam_role_policy.secrets_read: Refreshing state... [id=address-validation-lambda-dev:secrets-read]
aws_iam_role_policy.dlq_send: Refreshing state... [id=address-validation-lambda-dev:dlq-send]
aws_iam_role_policy.lambda_logs: Refreshing state... [id=address-validation-lambda-dev:cloudwatch-logs]
aws_lambda_function.handler: Refreshing state... [id=address-validation-handler-dev]
aws_lambda_function.authorizer: Refreshing state... [id=address-validation-authorizer-dev]
aws_iam_role_policy_attachment.xray: Refreshing state... [id=address-validation-lambda-dev-20260323021610749600000001]
aws_lambda_function.health: Refreshing state... [id=address-validation-health-dev]
aws_lambda_permission.api_gateway_health: Refreshing state... [id=AllowAPIGatewayInvokeHealth]
aws_apigatewayv2_integration.health: Refreshing state... [id=6ktcygu]
aws_lambda_permission.api_gateway_handler: Refreshing state... [id=AllowAPIGatewayInvokeHandler]
aws_apigatewayv2_integration.handler: Refreshing state... [id=s8f1dfh]
aws_cloudwatch_metric_alarm.handler_errors: Refreshing state... [id=address-validation-handler-errors-dev]
aws_cloudwatch_metric_alarm.handler_duration: Refreshing state... [id=address-validation-handler-duration-dev]
aws_cloudwatch_metric_alarm.handler_throttles: Refreshing state... [id=address-validation-handler-throttles-dev]
aws_lambda_permission.authorizer_invoke: Refreshing state... [id=AllowAPIGatewayInvokeAuthorizer]
aws_apigatewayv2_authorizer.api_key: Refreshing state... [id=64l2kl]
aws_cloudwatch_metric_alarm.authorizer_errors: Refreshing state... [id=address-validation-authorizer-errors-dev]
aws_apigatewayv2_route.health: Refreshing state... [id=8s7aw6n]
aws_apigatewayv2_route.validate: Refreshing state... [id=n68uzib]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_lambda_function.authorizer will be updated in-place
  ~ resource "aws_lambda_function" "authorizer" {
        id                             = "address-validation-authorizer-dev"
      ~ last_modified                  = "2026-04-16T04:49:29.000+0000" -> (known after apply)
      ~ source_code_hash               = "Pc1aq9OfH2otHtA7buvXqvfF9EoZXHuvr8n1o1wNczE=" -> "nnH2pTovRpwnZC/x983GvTjWQDFqnzB6BYD9MNISSmc="
        tags                           = {}
        # (21 unchanged attributes hidden)

        # (4 unchanged blocks hidden)
    }

  # aws_lambda_function.handler will be updated in-place
  ~ resource "aws_lambda_function" "handler" {
        id                             = "address-validation-handler-dev"
      ~ last_modified                  = "2026-04-16T04:49:41.000+0000" -> (known after apply)
      ~ source_code_hash               = "Pc1aq9OfH2otHtA7buvXqvfF9EoZXHuvr8n1o1wNczE=" -> "nnH2pTovRpwnZC/x983GvTjWQDFqnzB6BYD9MNISSmc="
        tags                           = {}
        # (21 unchanged attributes hidden)

        # (5 unchanged blocks hidden)
    }

  # aws_lambda_function.health will be updated in-place
  ~ resource "aws_lambda_function" "health" {
        id                             = "address-validation-health-dev"
      ~ last_modified                  = "2026-04-16T04:49:35.000+0000" -> (known after apply)
      ~ source_code_hash               = "Pc1aq9OfH2otHtA7buvXqvfF9EoZXHuvr8n1o1wNczE=" -> "nnH2pTovRpwnZC/x983GvTjWQDFqnzB6BYD9MNISSmc="
        tags                           = {}
        # (21 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 3 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

Triggered by @mcrundo in commit 2b4dd49

@mcrundo mcrundo merged commit 36fafb4 into main Apr 16, 2026
4 checks passed
@mcrundo mcrundo deleted the fix-country-default branch April 16, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant