From 6fe1da3219a302242e67d92bb1f786e219a5eeb8 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:25:01 -0400 Subject: [PATCH] fix(iam): word the account property key refusal as AWS does (#9161) A key that satisfies the published shape and is not Namespace/PropertyName answers 'Property key must be in format Namespace/PropertyName: ', recorded for a key carrying no separator, with the key as the request sent it. This package described the rule in a sentence of its own instead. The rule itself is unchanged, and the layer AWS applies after it is left out on purpose rather than guessed: an unrecognised namespace is refused there, and building that check needs the set of namespaces AWS recognises, which the recordings do not give. The IAM page says so. --- docs/services/iam.md | 23 +++++++++++++++++++ .../io/floci/aws/services/iam/IamService.java | 8 ++++--- .../iam/AccountPropertiesIntegrationTest.java | 7 ++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/docs/services/iam.md b/docs/services/iam.md index 7ce63054ea..087d5bf742 100644 --- a/docs/services/iam.md +++ b/docs/services/iam.md @@ -1709,6 +1709,29 @@ it is STS itself: Floci does not vary its token format by account preference, so observable in the summary rather than in a token. `v1Token` is reported as the default for an account that has never set one. +### What a bad account property key answers + +A property key is read in three layers and two of them are settled by recordings. + +A key breaking the published shape, `accountPropertyKeyType` at 1 to 50 characters matching +`^[A-Za-z][A-Za-z0-9/_-]*$`, is the declared constraint violation, a `ValidationError` naming the +map's keys, which is what AWS answers and what this package already gave. + +A key that satisfies the shape and is not `Namespace/PropertyName` is `InvalidInput` 400 with +`Property key must be in format Namespace/PropertyName: `, recorded 2026-11-06 for a key +carrying no separator at all, the key echoed as the request sent it. This package answered a +sentence of its own describing the rule; the rule itself is unchanged, and the two other spellings +it refuses, a trailing slash and several slashes, carry the same sentence without a recording of +their own. + +The third layer is not implemented and is tracked rather than guessed. AWS also refuses a key whose +namespace it does not recognise, `InvalidInput` 400 with `Unsupported namespace: `, +recorded 2026-10-25, where this emulator stores the property under whatever namespace the key +names. Doing it needs the set of namespaces AWS recognises, and the recordings name exactly one +real namespace and one invented one, so a check built from them would refuse namespaces AWS +accepts. That is the wrong direction to be wrong in, so the set has to come from a source that +publishes it. + ### Organizations Root Access | Action | Description | diff --git a/src/main/java/io/floci/aws/services/iam/IamService.java b/src/main/java/io/floci/aws/services/iam/IamService.java index 72a4387722..30a5a6c445 100644 --- a/src/main/java/io/floci/aws/services/iam/IamService.java +++ b/src/main/java/io/floci/aws/services/iam/IamService.java @@ -3483,10 +3483,12 @@ public class IamService implements SessionAccountLookup, ResourceProvider { private String accountPropertyNamespace(String key) { int separator = key == null ? -1 : key.indexOf('/'); if (separator <= 0 || separator != key.lastIndexOf('/') || separator == key.length() - 1) { + // AWS's own fixed text for this refusal, carrying the key exactly as the request + // sent it, so nothing here may reword it or trim the key. Which spellings reach it is + // this package's reading: no slash, several, and a trailing one share the sentence. + // The IAM page carries the recording behind it and what it does and does not cover. throw new AwsException("InvalidInput", - "The property key '" + key + "' is not Namespace/PropertyName: a key has " - + "exactly one forward slash, and neither a leading nor a trailing " - + "one.", 400); + "Property key must be in format Namespace/PropertyName: " + key, 400); } return key.substring(0, separator); } diff --git a/src/test/java/io/floci/aws/services/iam/AccountPropertiesIntegrationTest.java b/src/test/java/io/floci/aws/services/iam/AccountPropertiesIntegrationTest.java index 7f72e13d8f..7e13f618aa 100644 --- a/src/test/java/io/floci/aws/services/iam/AccountPropertiesIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/iam/AccountPropertiesIntegrationTest.java @@ -102,7 +102,10 @@ class AccountPropertiesIntegrationTest { /** * These three satisfy the published pattern, which admits no slash, several, and a trailing * one, and fail only the Namespace/PropertyName rule. The service applies that after the - * format is already good, so it is {@code InvalidInput} rather than a constraint failure. + * format is already good, so it is {@code InvalidInput} rather than a constraint failure, and + * the sentence is the one AWS was recorded answering for the key that carries no separator, + * with the key as the request sent it. The other two spellings are this package's own rule + * under the same sentence, nothing recording what AWS answers for them. */ @Test void aKeyThatIsNotNamespaceSlashPropertyIsInvalidInput() { @@ -115,7 +118,7 @@ class AccountPropertiesIntegrationTest { .body(not(containsString("ValidationError"))) // The wording matters as much as the code here: carrying the constraint phrasing // on an InvalidInput is the mismatch this split exists to remove. - .body(containsString("is not Namespace/PropertyName")) + .body(containsString("Property key must be in format Namespace/PropertyName: " + key)) .body(not(containsString("failed to satisfy constraint"))); } }