fix(iam): match status validation errors for credential updates (#7174)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-11-01 09:12:08 -04:00
1 parent a707cb3260
commit a54ca5e0c9
10 files changed
+109 -50

No files matched your search

@@ -168,9 +168,9 @@ public final class SmithyValidationErrors {
* what {@code docs/services/iam.md} records as the reading. Choosing a form here rather than at
* each message means a later capture changes one object instead of a package.
*
* <p>Only the violations that carry a value differ. A required member the request leaves out
* ({@link #notNull}), a list held to its member count ({@link #sizeOutOfRange}) and a list
* checked as a whole ({@link #notAllInEnum}) read the same either way.
* <p>This form applies only to violations that carry a value. Required-member omissions use
* {@link #notNull} or {@link #notNullWithoutValue}, depending on the operation. List size and
* whole-list checks use {@link #sizeOutOfRange} and {@link #notAllInEnum} separately.
*/
public static final class Violations {
@@ -1274,9 +1274,7 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
* five entities and passes everything else through, which would make the {@code Role} this
* action and {@code GetRole} answer unparsable.
*
* <p>The rendering names neither the offending value nor the set, the way
* {@link #requireStatusFromEnum} does, which is the one IAM constraint rendering a recording
* covers. It also keeps the refused description out of the error body, where a control
* <p>The rendering keeps the refused description out of the error body, where a control
* character would break the answer it is being refused for.
*/
private static void validateRoleDescription(String description) {
@@ -3452,17 +3450,18 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
// =========================================================================
/**
* {@code statusType}, shared by UpdateAccessKey, UpdateSigningCertificate, UpdateSSHPublicKey
* and UpdateServiceSpecificCredential. One rendering serves all four because one front end
* validates one shape: the recording is of UpdateServiceSpecificCredential, and AWS names
* neither the offending value nor the permitted set, unlike this message elsewhere in the
* tree. Matched rather than made uniform.
* {@code statusType} is shared by four credential updates. AWS distinguishes a missing member
* from an invalid value and lists the permitted values in its recorded error-message order.
*/
private void requireStatusFromEnum(String status) {
if (status == null || !CREDENTIAL_STATUSES.contains(status)) {
if (status == null) {
throw SmithyValidationErrors.validationError(
"Value at 'status' failed to satisfy "
+ "constraint: Member must satisfy enum value set");
SmithyValidationErrors.notNullWithoutValue("status"));
}
if (!CREDENTIAL_STATUSES.contains(status)) {
throw SmithyValidationErrors.validationError(
IamValidationErrors.MESSAGES.notInEnum(status, "status",
List.of(CREDENTIAL_STATUS_EXPIRED, CREDENTIAL_STATUS_ACTIVE, "Inactive")));
}
}
@@ -10,9 +10,9 @@ import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
* where the older ones quoted the value, and STS still quotes it, so this names IAM's side of that
* split in one place. {@code docs/services/iam.md} records the reading and the captures behind it.
*
* <p>A message AWS itself writes with the value is not forced through here: a list checked as a
* whole carries the list, and a required member the request leaves out reads
* {@code Value null at '<member>'}, which no capture here covers either way.
* <p>A list checked as a whole can carry the list and is not forced through here. Required-member
* omissions use operation-specific wording: the captured missing {@code Status} on credential
* updates reads {@code Value at 'status'} without {@code null}.
*/
final class IamValidationErrors {