refactor(core): add AwsArnUtils.looksLikeArn for name-or-ARN parameters (#6877)

A parameter that takes a name or an ARN, where AWS answers a malformed ARN with its own error, needs to treat any value starting arn: as an attempted ARN. isArn needs all six fields and would send arn:aws:rds down the name path, so the sites the earlier migration PRs left on purpose still probe with a hand-written startsWith. looksLikeArn is that probe, in one place, so the area PRs that follow can move them off the arn-probe baseline without changing the error a caller sees.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-28 20:47:03 -04:00
1 parent d726533659
commit 22ea3ca2e0
3 files changed
+37 -1

No files matched your search

@@ -248,6 +248,29 @@ class AwsArnUtilsTest {
assertFalse(AwsArnUtils.isArn(null));
}
@ParameterizedTest
@ValueSource(strings = {"arn:aws:sqs:us-east-1:000000000000:q", "arn:aws-cn:rds", "arn:"})
void looksLikeArnAcceptsAnyValueMeantAsAnArn(String value) {
assertTrue(AwsArnUtils.looksLikeArn(value));
}
@ParameterizedTest
@ValueSource(strings = {"my-queue", "", " ", "ARN:aws:sqs:us-east-1:000000000000:q", " arn:aws:sqs"})
void looksLikeArnRejectsNames(String value) {
assertFalse(AwsArnUtils.looksLikeArn(value));
}
@Test
void looksLikeArnRejectsNullRatherThanThrowing() {
assertFalse(AwsArnUtils.looksLikeArn(null));
}
@Test
void looksLikeArnAcceptsAMalformedArnThatIsArnRejects() {
assertTrue(AwsArnUtils.looksLikeArn("arn:aws:rds:us-east-1"));
assertFalse(AwsArnUtils.isArn("arn:aws:rds:us-east-1"));
}
/**
* The shape the {@code startsWith("arn:aws:dynamodb:")} probes were reaching for: is this
* identifier an ARN for my service, whatever partition it came from.