fix(iam): read a status and a service principal from the model (#7265)

Two members were held back from the vendored shapes because this service was
read as answering them in a wording of its own. Captures from a real account,
posted on issue #6042, answer both, and neither reading holds.

`statusType` is shared by `UpdateAccessKey`, `UpdateSigningCertificate`,
`UpdateSSHPublicKey` and `UpdateServiceSpecificCredential`. One hand-written
check answered all four, naming neither the offending value nor the permitted
set, which is what a 2025 recording of one of them carries. AWS names the set,
`Member must satisfy enum value set: [Expired, Active, Inactive]`, and answers
an omitted status as the required member it is rather than as a value outside
the set, which one check reading a null as a bad value could not tell apart.
Both are the model's own wording, so all four read it through the Query front
door and the check comes out.

The set is listed in the order AWS lists it, which is not the order botocore
declares. The values are the model's and the generator holds them to it: only
their order is read from the capture.

`AWSServiceName` on `CreateServiceLinkedRole` answered `InvalidInput` with a
sentence about its own bounds, where AWS answers a constraint violation naming
the declared pattern. A principal that satisfies the pattern and names no
service AWS has is still `InvalidInput`, so the layering the capture leaves in
place is the shape first and then whether the service exists.

The required-member message loses the word that stood where the value would
go. IAM names a member and leaves its value out everywhere, and the one
message carrying `Value null at` did so for want of a capture either way; the
capture answers `Value at 'status'`. The form moves in the one object that
decides it, so the eight refusals this package writes by hand move with the
walk, and the services that do quote their values keep the word.

The message quotes the pattern AWS quotes, which is not the one the shape
declares. botocore aliases that member to the shape it gives a group name,
`[\w+=,.@-]+` at 1 to 128 characters, where AWS's message gives
`[\w+=.@-]*`: the comma is gone and a `*` stands where the minimum is 1.
Only the message is in hand rather than the shape, so the generator records
AWS's text beside the model's and one object decides which text any
violation quotes, the way the enum order is read from the capture while the
values stay the model's. A comma is still admitted and an empty principal
still refused, and an empty one now breaks the minimum and the pattern at
once, as every other string member here does. The comma is what a second
capture would settle, and the difference is recorded in
`docs/services/iam.md`.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-02 07:53:11 -06:00
1 parent 9fc5be5ceb
commit b4c539d009
26 files changed
+502 -194

No files matched your search

@@ -155,6 +155,31 @@ class QueryConstraintCheckTest {
"Status", "Pending")));
}
/**
* One member quotes a pattern AWS gives for it rather than the one the model declares, which
* the vendored shape records beside it. What a value is held to stays the model's: the comma
* the model admits and the quoted text does not is still admitted.
*/
@Test
void aShapeRecordingACapturedPatternQuotesItAndStillMatchesTheModels() throws Exception {
QueryConstraintCheck check = QueryConstraintCheck.of(MAPPER.readTree("""
{
"operations": {"Link": "LinkRequest"},
"shapes": {
"LinkRequest": {"type": "structure", "required": ["Principal"], "members": {
"Principal": "principalType"}},
"principalType": {"type": "string", "min": 1, "max": 128,
"pattern": "[\\\\w+=,.@-]+", "quotedPattern": "[\\\\w+=.@-]*"}
}
}
"""));
assertEquals(List.of("Value 'not a principal' at 'principal' failed to satisfy constraint: "
+ "Member must satisfy regular expression pattern: [\\w+=.@-]*"),
check.violations("Link", params("Principal", "not a principal")));
assertEquals(List.of(), check.violations("Link", params("Principal", "es,amazonaws.com")));
}
/** A number is held to its range, and one that is no number at all is left to the operation. */
@Test
void aNumberIsHeldToItsRangeAndANonNumberIsLeftToTheOperation() throws Exception {
@@ -20,8 +20,9 @@ class RequestConstraintCheckTest {
"shapes": {
"PutInput": {"type": "structure", "required": ["name"],
"members": {"name": "Name", "items": "Items", "count": "Count", "labels": "Labels",
"kind": "Kind"}},
"kind": "Kind", "quoted": "Quoted"}},
"Name": {"type": "string", "min": 2, "max": 5, "pattern": "[a-z]+"},
"Quoted": {"type": "string", "pattern": "[a-z]+", "quotedPattern": "[a-z]*"},
"Items": {"type": "list", "max": 2, "member": "Item"},
"Item": {"type": "structure", "required": ["id"], "members": {"id": "Name"}},
"Count": {"type": "integer", "min": 1, "max": 10},
@@ -82,6 +83,8 @@ class RequestConstraintCheckTest {
assertEquals("bounds Put.name string 2..5 1", violation("{\"name\":\"a\"}"));
assertEquals("bounds Put.name string 2..5 6", violation("{\"name\":\"abcdef\"}"));
assertEquals("pattern Put.name [a-z]+", violation("{\"name\":\"AB\"}"));
// A shape recording the pattern AWS quotes for its member hands that text over instead.
assertEquals("pattern Put.quoted [a-z]*", violation("{\"name\":\"ab\",\"quoted\":\"AB\"}"));
assertEquals("bounds Put.count integer 1..10 11", violation("{\"name\":\"ab\",\"count\":11}"));
assertEquals("type Put.count integer", violation("{\"name\":\"ab\",\"count\":1.5}"));
assertEquals("enum Put.kind [A, B]", violation("{\"name\":\"ab\",\"kind\":\"C\"}"));
@@ -1,11 +1,13 @@
package io.github.hectorvent.floci.core.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -67,4 +69,27 @@ class VendoredPatternsTest {
assertTrue(asWritten.matcher(c1Control).matches(),
"and admits what the model excludes");
}
/**
* Which text a violation quotes is this object's other answer. It is the pattern the model
* declares, except for a member whose message AWS gives a pattern of its own for, where the
* vendored shape records both: what is matched on stays the model's either way.
*/
@Test
void theQuotedTextIsTheCapturedPatternWhereTheShapeRecordsOneAndTheModelsOtherwise() throws Exception {
ObjectMapper mapper = new ObjectMapper();
assertEquals("[\\w+=.@-]*", VendoredPatterns.quoted(mapper.readTree("""
{"type": "string", "min": 1, "max": 128,
"pattern": "[\\\\w+=,.@-]+", "quotedPattern": "[\\\\w+=.@-]*"}
""")));
assertEquals("[\\w+=,.@-]+", VendoredPatterns.quoted(mapper.readTree("""
{"type": "string", "pattern": "[\\\\w+=,.@-]+"}
""")),
"a shape recording no captured text quotes the one it declares");
assertNull(VendoredPatterns.quoted(mapper.readTree("""
{"type": "string", "min": 1}
""")),
"and a shape with no pattern at all quotes none");
}
}
@@ -150,13 +150,14 @@ class AccountPropertiesIntegrationTest {
void anAbsentPropertiesMapIsRejected() {
iam("PutAccountProperties").when().post("/").then().statusCode(400)
.body(containsString("ValidationError"))
// Recorded against AWS on SNS's own map member, down to the phrasing:
// "1 validation error detected: Value null at 'attributes' failed to satisfy
// constraint: Member must not be null".
// IAM's own form, captured from a real account on 2026-10-31 against the Status the
// four credential operations share: "1 validation error detected: Value at 'status'
// failed to satisfy constraint: Member must not be null". SNS, which quotes its
// values, carries a null where the value would go; IAM leaves it out with the rest.
.body(containsString("1 validation error detected"))
// The apostrophes around the member name come back XML-escaped, so the assertion
// stops at the parts that survive escaping.
.body(containsString("Value null at "))
.body(containsString("Value at "))
.body(containsString("properties"))
.body(containsString("Member must not be null"));
}
@@ -25,8 +25,12 @@ import static org.hamcrest.Matchers.equalTo;
* implicitly based on the AWS access key ID used to sign the request", the sentence this operation
* shares with DeleteAccessKey and ListAccessKeys.
*
* <p>The four operations share {@code IamService.requireStatusFromEnum}; the latest AWS captures
* distinguish an absent status from a present value outside the enum.
* <p>Both refusals were captured from a real account on 2026-10-31, against all four operations
* that share this shape: a value outside the set is answered with the set named and the value left
* out, in the order AWS lists it rather than the order the model declares, and an omitted status is
* answered as the required member it is rather than as a value outside the set. Both are the
* model's own wording, read through the Query front door, where three hand-written renderings
* stood before.
*/
@QuarkusTest
class IamAccessKeyStatusIntegrationTest {
@@ -66,6 +70,10 @@ class IamAccessKeyStatusIntegrationTest {
assertStatusStillActive(userName);
}
/**
* An omitted status is the required member reading as null, not a value outside the set, which
* is what the capture answers and what the rendering this replaced could not tell apart.
*/
@Test
void anAbsentStatusNamesTheMissingMember() {
String userName = user("absent-status");
@@ -91,7 +99,7 @@ class IamAccessKeyStatusIntegrationTest {
void anAbsentAccessKeyIdNamesItself() {
update(ACCOUNT, Map.of("UserName", user("absent-id"), "Status", "Inactive")).statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", containsString("Value null at 'accessKeyId'"));
.body("ErrorResponse.Error.Message", containsString("Value at 'accessKeyId'"));
}
@Test
@@ -1717,8 +1717,8 @@ class IamIntegrationTest {
.when().post("/").then()
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value null"
+ " at 'roleName' failed to satisfy constraint: Member must not be null"));
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
+ " 'roleName' failed to satisfy constraint: Member must not be null"));
given()
.formParam("Action", "CreateRole")
@@ -65,7 +65,7 @@ class IamRequestConstraintsIntegrationTest {
void aRequiredMemberLeftOutIsReportedAsNull() {
iam("DeletePolicy").when().post("/").then().statusCode(400)
.body(CODE, equalTo("ValidationError"))
.body(MESSAGE, equalTo("1 validation error detected: Value null at 'policyArn' failed"
.body(MESSAGE, equalTo("1 validation error detected: Value at 'policyArn' failed"
+ " to satisfy constraint: Member must not be null"));
}
@@ -339,7 +339,7 @@ class IamRequestConstraintsIntegrationTest {
// A map the request names nowhere is the required member reading as null.
iam("PutAccountProperties")
.when().post("/").then().statusCode(400)
.body(MESSAGE, equalTo("1 validation error detected: Value null at 'properties' failed"
.body(MESSAGE, equalTo("1 validation error detected: Value at 'properties' failed"
+ " to satisfy constraint: Member must not be null"));
}
@@ -357,7 +357,7 @@ class IamRequestConstraintsIntegrationTest {
.formParam("ReplacementValues.entry.1.key", "Department")
.when().post("/").then().statusCode(400)
.body(CODE, equalTo("ValidationError"))
.body(MESSAGE, equalTo("1 validation error detected: Value null at"
.body(MESSAGE, equalTo("1 validation error detected: Value at"
+ " 'replacementValues.Department.values' failed to satisfy constraint: Member"
+ " must not be null"));
}
@@ -147,7 +147,7 @@ class IamRoleDescriptionIntegrationTest {
update(Map.of("RoleName", roleName)).statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message",
equalTo("1 validation error detected: Value null at 'description' failed "
equalTo("1 validation error detected: Value at 'description' failed "
+ "to satisfy constraint: Member must not be null"));
admin("GetRole", Map.of("RoleName", roleName)).statusCode(200)
@@ -145,6 +145,12 @@ class IamServiceLinkedRoleIntegrationTest {
equalTo("AWSServiceRoleForEs_debug"));
}
/**
* The member is required in the model, so it is answered as a required member rather than as a
* value that failed its pattern. The whole operation moved onto the model on 2026-10-31, when
* a capture from a real account showed AWS answering a bad principal as a constraint violation
* and not as the {@code InvalidInput} this service used to write for itself.
*/
@Test
@Order(5)
void aMissingServiceNameIsRejected() {
@@ -156,9 +162,8 @@ class IamServiceLinkedRoleIntegrationTest {
.then()
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo(
"1 validation error detected: Value null at 'aWSServiceName' failed to satisfy constraint: "
+ "Member must not be null"));
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
+ " 'aWSServiceName' failed to satisfy constraint: Member must not be null"));
}
@Test
@@ -322,6 +327,12 @@ class IamServiceLinkedRoleIntegrationTest {
equalTo("AWSServiceRoleForAutoScaling_CustomResource"));
}
/**
* The captured answer, from a real account on 2026-10-31: a principal that breaks the pattern
* is a constraint violation naming the member, with no value beside it and with AWS's own
* pattern quoted, which is the one the vendored shape carries for this member's message. The
* whole message is pinned, so a value leaking back into it fails here.
*/
@Test
@Order(15)
void aServiceNameWithSpacesMatchesAwsValidationError() {
@@ -339,7 +350,12 @@ class IamServiceLinkedRoleIntegrationTest {
+ "Member must satisfy regular expression pattern: [\\w+=.@-]*"));
}
/** The documented name pattern rejects these characters before any role lookup. */
/**
* AWS constrains AWSServiceName to 1 to 128 characters of its own pattern; anything else must
* not reach storage. Each of these is a constraint the model declares, so each is a
* {@code ValidationError} naming the member: the first four break the pattern and the last the
* maximum length.
*/
@Test
@Order(15)
void aServiceNameOutsideTheAwsPatternIsRejected() {
@@ -352,10 +368,17 @@ class IamServiceLinkedRoleIntegrationTest {
.post("/")
.then()
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"));
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", containsString("at 'aWSServiceName'"));
}
}
/**
* A principal sent empty breaks the minimum and the pattern at once, and the walk reports each
* constraint the value broke rather than the first, which is what every other string member
* here answers for an empty value. Nothing captured covers an empty principal: the two
* constraints are the model's and the form is this service's own.
*/
@Test
@Order(15)
void anEmptyServiceNameUsesIamValidationError() {
@@ -369,8 +392,10 @@ class IamServiceLinkedRoleIntegrationTest {
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo(
"1 validation error detected: Value at 'aWSServiceName' failed to satisfy constraint: "
+ "Member must have length greater than or equal to 1"));
"2 validation errors detected: Value at 'aWSServiceName' failed to satisfy constraint: "
+ "Member must have length greater than or equal to 1; Value at 'aWSServiceName'"
+ " failed to satisfy constraint: Member must satisfy regular expression"
+ " pattern: [\\w+=.@-]*"));
}
@Test
@@ -1241,7 +1241,7 @@ class IamServiceTest {
AwsException missing = assertThrows(AwsException.class,
() -> iamService.changePassword("alice", null, "An0ther$ecret!"));
assertEquals("ValidationError", missing.getErrorCode());
assertTrue(missing.getMessage().contains("Value null at 'oldPassword'"), missing.getMessage());
assertTrue(missing.getMessage().contains("Value at 'oldPassword'"), missing.getMessage());
// An empty member is a value that fails the pattern rather than a member never supplied,
// and the message names the one that failed, there being two password members here.
@@ -2181,37 +2181,6 @@ class IamServiceTest {
}
}
@Test
void anAccessKeyStatusIsReadBeforeTheKeyIsFound() {
// The key does not exist either, and the status is what answers: AWS reads a request's
// shape before it resolves anything, so the lookup's NoSuchEntity does not get there first.
iamService.createUser("alice", "/");
AwsException error = assertThrows(AwsException.class,
() -> iamService.updateAccessKey("alice", "AKIANOSUCHKEY00000", "Disabled"));
assertEquals("ValidationError", error.getErrorCode());
// AWS lists the allowed values in its error message, even when the key is unknown.
assertEquals("1 validation error detected: Value at 'status' failed to satisfy "
+ "constraint: Member must satisfy enum value set: [Expired, Active, Inactive]",
error.getMessage());
}
@Test
void anAbsentAccessKeyStatusNamesTheMissingMember() {
iamService.createUser("alice", "/");
AccessKey key = iamService.createAccessKey("alice");
AwsException error = assertThrows(AwsException.class,
() -> iamService.updateAccessKey("alice", key.getAccessKeyId(), null));
assertEquals("ValidationError", error.getErrorCode());
assertEquals("1 validation error detected: Value at 'status' failed to satisfy "
+ "constraint: Member must not be null", error.getMessage());
// And the key is as it was: the status is read before the lookup, so nothing is written.
assertEquals("Active", iamService.listAccessKeys("alice").getFirst().getStatus());
}
@Test
void aSessionWithNoRoleAndNoRecordedIssuerIsNoCredential() {
// How GetSessionToken stored its sessions before it recorded the key that minted them. Such
@@ -316,7 +316,7 @@ class OrganizationsAccessReportIntegrationTest {
iam(MANAGEMENT_ACCOUNT, "GenerateOrganizationsAccessReport")
.when().post("/").then().statusCode(400)
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value"
+ " null at 'entityPath' failed to satisfy constraint: Member must not be"
+ " at 'entityPath' failed to satisfy constraint: Member must not be"
+ " null"));
}
@@ -87,7 +87,7 @@ class RoleTemplateIntegrationTest {
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value "
+ "null at 'templateArn' failed to satisfy constraint: Member must not be "
+ "at 'templateArn' failed to satisfy constraint: Member must not be "
+ "null"))
.body(not(containsString("NoSuchEntity")));
}
@@ -175,7 +175,7 @@ class RoleTemplateIntegrationTest {
.when().post("/").then()
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value null "
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value "
+ "at 'replacementValues.Department.values' failed to satisfy constraint: "
+ "Member must not be null"))
.body(not(containsString("NoSuchEntity")));
@@ -254,7 +254,7 @@ class RoleTemplateIntegrationTest {
.formParam("ReplacementValues.entry.01.key", "Department")
.when().post("/").then()
.statusCode(400)
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value null "
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value "
+ "at 'replacementValues.Department.values' failed to satisfy constraint: "
+ "Member must not be null"));
}
@@ -280,8 +280,8 @@ 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 null at 'replacementValues.Parameter2."
+ "values' failed to satisfy constraint: Member must not be null; Value null "
+ "less than or equal to 30; Value at 'replacementValues.Parameter2."
+ "values' failed to satisfy constraint: Member must not be null; Value "
+ "at 'replacementValues.Parameter10.values' failed to satisfy constraint: "
+ "Member must not be null"));
}