fix(iam): name a map entry's field under .member, as AWS does (#7457)

A violation inside a map entry's structure named the entry and then the
field, replacementValues.Department.values. An AWS-validated recording of
the same protocol writes a segment between the two: SNS answers a missing
DataType inside its MessageAttributes map as

  1 validation error detected: Value null at
  'messageAttributes.attr1.member.dataType' failed to satisfy constraint:
  Member must not be null

and, inside a list's member,
publishBatchRequestEntries.1.member.messageAttributes.attr1.member.dataType.
So a map of structures is named the way a list of structures already is
here, the entry's key standing where a list's index stands, and the walk
now writes replacementValues.Department.member.values. AcquireRole is the
one operation that reaches it, its ReplacementValues being the only
structure-valued map these two services vendor.

What stays is the scalar-valued map. Nothing recorded covers one on this
protocol, and the only recording anywhere, Lambda's
routingConfig.additionalVersionWeights on REST-JSON, answers the map rather
than the entry with "Map value must satisfy constraint: [...]". A different
protocol and a different service is not evidence against the answer this
service already gave, so properties.Team/Owner stays as it is, with what
would move it written down beside it.

The core walk had no test for a structure under a map's key at all, every
case in that file holding a scalar, so one is added there rather than left
to the two IAM wire tests that quote the path.

docs/services/iam.md carries both halves, the recorded one and the open
one. The message's other half, the word null in the value slot, is IAM's
own and does not move: that service leaves it out and this is only the path.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-03 23:18:09 -06:00
1 parent d098a4729a
commit a90b812cc6
5 files changed
+89 -36

No files matched your search

+26 -14
View File
@@ -159,11 +159,14 @@ violation at once, the map's own length ahead of its entries. An entry's values
member being present rather than by what it holds, the list's members publishing no constraint of
their own, so a replacement value sent empty is a value.
The message for a broken entry names it by its key, as `replacementValues.Department.values`, which
is how IAM reports a bad value in its account properties map. No recorded AWS violation on a map
member is on hand to confirm that spelling, so it is Floci's reading of it: a capture would either
keep it or replace it with the nested form, where the path is the map itself and the constraint
reads "Map value must satisfy constraint".
The message for a broken entry names it by its key and then the field under `.member`, as
`replacementValues.Department.member.values`. The key half is how IAM reports a bad value in its
account properties map; the `.member` half comes from an AWS-validated recording of the same
protocol, SNS answering a missing `DataType` inside its `MessageAttributes` map as `Value null at
'messageAttributes.attr1.member.dataType'`, and inside a list's member as
`publishBatchRequestEntries.1.member.messageAttributes.attr1.member.dataType`. So a map of
structures is named the way a list of structures is, the entry's key standing where a list's index
stands.
### Policies
@@ -222,15 +225,24 @@ breaking a minimum of 1. A structure member arrives as `TaskPolicyArn.Arn` and i
A map is read the same way, from the entries the protocol numbers under its name:
`ReplacementValues.entry.1.key` and `.entry.1.value`, which is the form `AcquireRole`'s own sample
publishes, or the bare `ReplacementValues.1.key`. An entry's value is named under the key that
entry carries, `replacementValues.Department.values` and `properties.Team/Owner`, which is how both
maps this service answered by hand already named one and how the JSON protocols name a map's value
here. An entry is read off its key, so one numbered with a value and no key is not an entry the map
could hold: it is neither counted nor answered. The count is held to the map's own bounds with the
value left out of the message, and a map the request names nowhere is how an absent map arrives, so
a required one reads as null. A key outside its shape's rules is answered with the whole set that
shape declares, nested under the map's own name, `Value at 'properties' failed to satisfy
constraint: Map keys must satisfy constraint: [...]`, which is the form every map key recorded here
carries and what this service already answered for an account property key.
entry carries, `replacementValues.Department.member.values` and `properties.Team/Owner`, which is
how both maps this service answered by hand already named one and how the JSON protocols name a
map's value here. A value that is a structure carries `.member` between the key and the field, as
AWS writes it on this protocol and as a list of structures already reads here. A scalar value is
named at the key itself: nothing recorded covers one on this protocol, and the only recording of a
scalar-valued map anywhere, Lambda's `routingConfig.additionalVersionWeights` on REST-JSON,
answers the map rather than the entry, `Value '{2=-1.0}' at
'routingConfig.additionalVersionWeights' failed to satisfy constraint: Map value must satisfy
constraint: [...]`. That is a different protocol and a different service, so
`properties.Team/Owner` keeps the answer this service already gave, and a recording of a
scalar-valued map on the Query protocol is what would move it. An entry is read off its key, so
one numbered with a value and no key is not an entry the map could hold: it is neither counted nor
answered. The count is held to the map's own bounds with the value left out of the message, and a
map the request names nowhere is how an absent map arrives, so a required one reads as null. A key
outside its shape's rules is answered with the whole set that shape declares, nested under the
map's own name, `Value at 'properties' failed to satisfy constraint: Map keys must satisfy
constraint: [...]`, which is the form every map key recorded here carries and what this service
already answered for an account property key.
The two maps answered by hand are answered from the model now, and `AcquireRole`'s answers do not
move at all: its count of 30, each entry's required `Values` and the 20 values one entry admits read
@@ -50,10 +50,16 @@ import java.util.regex.Pattern;
* {@code Properties.entry.1.value}, or bare as {@code Properties.1.key}. An entry's value is named
* under the key the entry carries, {@code properties.Team/Owner}, which is how the hand-written
* checks these waves replace already named one and how {@link RequestConstraintCheck} names a map's
* value on the JSON protocols. An entry numbered with no key of its own is no entry the map could
* hold, so it is neither counted nor answered. A key outside its shape's rules is answered with the
* whole set the shape declares, nested under the map's own name, which is the form AWS answers for
* a map key everywhere this repository has one recorded.
* value on the JSON protocols. A value that is a structure carries {@code .member} between the key
* and the field, {@code replacementValues.Department.member.values}: that is the form AWS writes on
* this protocol, recorded against SNS as {@code messageAttributes.attr1.member.dataType}, and a
* list of structures already reads the same way, its index standing where the key stands. A scalar
* value is named at the key itself, which nothing recorded covers here: the one recording of a
* scalar-valued map, on another protocol, answers the map rather than the entry. An entry numbered
* with no key of its own is no entry the map could hold, so it is neither counted nor answered. A
* key outside its shape's rules is answered with the whole set the shape declares, nested under the
* map's own name, which is the form AWS answers for a map key everywhere this repository has one
* recorded.
*
* <p>Every one of those may hold any of the others: a structure's field may be a list, a list's
* member a map, a map's value a structure. A shape of some other type is one this walk would pass
@@ -242,10 +248,11 @@ public final class QueryConstraintCheck {
/**
* A map's entries, held to the map's own bounds and then each key and value to its shape. An
* entry arrives as {@code Properties.entry.1.key} and {@code Properties.entry.1.value}, and
* the value is named under the key the entry carries. An entry is read off that key, as the
* count of one has always been here, so one numbered with no key is not an entry the map could
* hold: it is neither counted nor answered.
* entry arrives as {@code Properties.entry.1.key} and {@code Properties.entry.1.value}, and the
* value is named under the key the entry carries, with {@code .member} after it where that
* value is a structure and the field inside it is what broke. An entry is read off that key, as
* the count of one has always been here, so one numbered with no key is not an entry the map
* could hold: it is neither counted nor answered.
*/
private List<String> mapViolations(JsonNode shape, String param, String path, boolean required,
MultivaluedMap<String, String> params) {
@@ -270,8 +277,9 @@ public final class QueryConstraintCheck {
if (structure) {
// An entry the request numbered with a key is an entry, so what the structure
// under it requires is answered inside it rather than the value reading as absent.
// The field sits under `.member` after the key, which is how AWS names one.
violations.addAll(structureViolations(shapes.path(valueShape), valueParam + ".",
valuePath + ".", params, Map.of()));
valuePath + ".member.", params, Map.of()));
} else {
violations.addAll(memberViolations(valueShape, valueParam, valuePath, true, params));
}
@@ -61,8 +61,12 @@ class QueryConstraintCheckTest {
"operations": {"Acquire": "AcquireRequest"},
"shapes": {
"AcquireRequest": {"type": "structure", "required": ["Values"], "members": {
"Values": "valueMap", "Nested": "nestedType", "Entries": "entryList"}},
"Values": "valueMap", "Nested": "nestedType", "Entries": "entryList",
"Replacements": "replacementMap"}},
"valueMap": {"type": "map", "key": "keyType", "value": "valueType", "max": 2},
"replacementMap": {"type": "map", "key": "keyType", "value": "replacementType"},
"replacementType": {"type": "structure", "required": ["Values"], "members": {
"Values": "nameList"}},
"nestedType": {"type": "structure", "members": {
"Arn": "arnType", "Parameters": "nameList"}},
"entryList": {"type": "list", "member": "entryType"},
@@ -564,6 +568,34 @@ class QueryConstraintCheckTest {
"Values.entry.3.key", "c", "Values.entry.3.value", "z")));
}
/**
* A map whose value is a structure names the field under {@code .member} after the key, which
* is the form AWS writes on this protocol: an AWS-validated SNS recording answers a missing
* {@code DataType} inside one as
* {@code Value null at 'messageAttributes.attr1.member.dataType'}. A scalar value stays at the
* key, as the test above has it, nothing recorded covering one here.
*/
@Test
void aStructureUnderAMapsKeyNamesItsFieldUnderMember() throws Exception {
// `keyType` is 4 characters, so the key is short enough to break nothing of its own and
// leave the field inside the entry as the only violation.
assertEquals(List.of("Value null at 'replacements.Dept.member.values' failed to satisfy"
+ " constraint: Member must not be null"),
maps().violations("Acquire", params(
"Values.entry.1.key", "k", "Values.entry.1.value", "ok",
"Replacements.entry.1.key", "Dept")));
assertEquals(List.of("Value at 'replacements.Dept.member.values' failed to satisfy"
+ " constraint: Member must have length less than or equal to 2"),
maps().violations("Acquire", params(
"Values.entry.1.key", "k", "Values.entry.1.value", "ok",
"Replacements.entry.1.key", "Dept",
"Replacements.entry.1.value.Values.member.1", "a",
"Replacements.entry.1.value.Values.member.2", "b",
"Replacements.entry.1.value.Values.member.3", "c")),
"and the list inside that structure is held to its own bounds under the same path");
}
/** A map the request names nowhere is the required member reading as null. */
@Test
void aMapNamedNowhereIsTheRequiredMemberReadingAsNull() throws Exception {
@@ -348,7 +348,8 @@ class IamRequestConstraintsIntegrationTest {
* deepest request this service models: {@code AcquireRole} numbers its replacement values as
* entries and each entry's structure carries a list of its own. An entry the request numbered
* with a key is an entry, so what the structure under it requires is answered inside it, named
* under that key, which is the answer the hand-written check this replaces already gave.
* under that key with {@code .member} after it, which is the form AWS writes for a map of
* structures on this protocol.
*/
@Test
void aMapValuesStructureAndTheListInsideItAreRead() {
@@ -358,8 +359,8 @@ class IamRequestConstraintsIntegrationTest {
.when().post("/").then().statusCode(400)
.body(CODE, equalTo("ValidationError"))
.body(MESSAGE, equalTo("1 validation error detected: Value at"
+ " 'replacementValues.Department.values' failed to satisfy constraint: Member"
+ " must not be null"));
+ " 'replacementValues.Department.member.values' failed to satisfy constraint:"
+ " Member must not be null"));
}
/**
@@ -176,8 +176,8 @@ class RoleTemplateIntegrationTest {
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value "
+ "at 'replacementValues.Department.values' failed to satisfy constraint: "
+ "Member must not be null"))
+ "at 'replacementValues.Department.member.values' failed to satisfy "
+ "constraint: Member must not be null"))
.body(not(containsString("NoSuchEntity")));
}
@@ -191,8 +191,8 @@ class RoleTemplateIntegrationTest {
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at "
+ "'replacementValues.Department.values' failed to satisfy constraint: Member "
+ "must have length less than or equal to 20"));
+ "'replacementValues.Department.member.values' failed to satisfy constraint: "
+ "Member must have length less than or equal to 20"));
acquireWithValues(20).when().post("/").then()
.statusCode(404)
@@ -255,8 +255,8 @@ class RoleTemplateIntegrationTest {
.when().post("/").then()
.statusCode(400)
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value "
+ "at 'replacementValues.Department.values' failed to satisfy constraint: "
+ "Member must not be null"));
+ "at 'replacementValues.Department.member.values' failed to satisfy "
+ "constraint: Member must not be null"));
}
/**
@@ -280,9 +280,9 @@ class RoleTemplateIntegrationTest {
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("3 validation errors detected: Value at "
+ "'replacementValues' failed to satisfy constraint: Member must have length "
+ "less than or equal to 30; Value at 'replacementValues.Parameter2."
+ "less than or equal to 30; Value at 'replacementValues.Parameter2.member."
+ "values' failed to satisfy constraint: Member must not be null; Value "
+ "at 'replacementValues.Parameter10.values' failed to satisfy constraint: "
+ "Member must not be null"));
+ "at 'replacementValues.Parameter10.member.values' failed to satisfy "
+ "constraint: Member must not be null"));
}
}