{"record":{"id":"fb5a157dc5b4b8e0","repo":"spring-projects/spring-ai","slug":"the-region-region-is-not-a-valid-region","errorCode":null,"errorMessage":"The region '<region>' is not a valid region!","messagePattern":"The region '<region>' is not a valid region!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/main/java/org/springframework/ai/model/bedrock/autoconfigure/BedrockAwsConnectionConfiguration.java","lineNumber":116,"sourceCode":"\tpublic AwsRegionProvider regionProvider(BedrockAwsConnectionProperties properties) {\n\n\t\tif (StringUtils.hasText(properties.getRegion())) {\n\t\t\treturn new StaticRegionProvider(properties.getRegion());\n\t\t}\n\n\t\treturn DefaultAwsRegionProviderChain.builder().build();\n\t}\n\n\tstatic class StaticRegionProvider implements AwsRegionProvider {\n\n\t\tprivate final Region region;\n\n\t\tStaticRegionProvider(String region) {\n\t\t\ttry {\n\t\t\t\tthis.region = Region.of(region);\n\t\t\t}\n\t\t\tcatch (IllegalArgumentException e) {\n\t\t\t\tthrow new IllegalArgumentException(\"The region '\" + region + \"' is not a valid region!\", e);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Region getRegion() {\n\t\t\treturn this.region;\n\t\t}\n\n\t}\n\n}\n","sourceCodeStart":98,"sourceCodeEnd":128,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/main/java/org/springframework/ai/model/bedrock/autoconfigure/BedrockAwsConnectionConfiguration.java#L98-L128","documentation":"BedrockAwsConnectionConfiguration's StaticRegionProvider converts the configured region string into an AWS SDK Region via Region.of(), which validates it against known AWS regions. If the string is not a recognized region identifier, Region.of throws IllegalArgumentException, which is re-wrapped with this clearer message naming the offending value.","triggerScenarios":"Setting spring.ai.bedrock.aws.region (or the BedrockAwsConnectionProperties region) to a value AWS SDK v2 does not recognize — misspelled region, wrong casing is fine but wrong format (e.g. 'us-east', 'eu', 'us-east-1a' style) triggers it at bean creation of the region provider.","commonSituations":"Typos like 'us-east-2 ' with whitespace, invented regions ('us-west-4'), copying a region name from another cloud, or an empty/placeholder value in application.yml.","solutions":["Set the region to a valid AWS region code such as us-east-1, us-west-2, eu-central-1, or ap-southeast-1.","Check for typos, whitespace, or placeholders in the spring.ai.bedrock.aws.region property.","Omit the property to let the default AWS region provider chain (env var, profile, EC2 metadata) resolve the region instead of a static one."],"exampleFix":"// before\nspring.ai.bedrock.aws.region=us-east\n// after\nspring.ai.bedrock.aws.region=us-east-1","handlingStrategy":"validation","validationCode":"String region = properties.getRegion();\nSet<String> valid = Region.regions().stream().map(Region::id).collect(Collectors.toSet());\nif (region != null && !valid.contains(region)) throw new IllegalArgumentException(\"Unknown AWS region: \" + region);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact AWS region codes (us-east-1, eu-west-1, ...).","Trim whitespace from region config values.","Prefer the default region provider chain over hardcoding when unsure."],"tags":["aws","bedrock","region","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}