mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(iam): open every ValidationError with the count AWS puts on it (#5280)
hectorvent asked on #5240 whether the account-property constraint messages should carry the "1 validation error detected: " prefix that #5239's two recorded messages have, noting there is no recording for PutAccountProperties itself. There is evidence, just not on that operation. Across the AWS-validated snapshots for IAM, CloudWatch and SNS, every recorded constraint message opens with the count: six of six. The prefix is the envelope the front end puts on a validation report, not a property of the member being validated, and SNS settles the part the question turned on, because two of its recordings are map members and both carry it: 1 validation error detected: Value null at 'attributes' failed to satisfy constraint: Member must not be null 1 validation error detected: Value null at 'messageAttributes.attr1.member.dataType' failed to satisfy constraint: Member must not be null The first of those is this change's absent-map case almost verbatim, down to "Value null at '<map>'". Looking for that turned up something wider than the question. IamQueryHandler's requireParam, which every required member in the service is read through, emitted its message without the prefix, while StsQueryHandler's validateRequired in the same package and TagDispatcher in core.common both already carry it on the identical sentence. IAM was the outlier, so one line fixes all 28 call sites. The five messages here are the four on the account-properties path and that one. Each was probed by reverting it on its own, and each fails only the tests that cover it. Three more constraint reports were still opening without the count, so the title did not hold when it was written: the ListPolicies scope enum, the GenerateServiceLastAccessedDetails granularity enum, and optionalInt. No test pinned any of their text, which is how they survived a change that touched every other one. A fourth, the CredentialAgeDays range check, survived a sweep for that phrase because its message builds "failed to " and "satisfy constraint" as separate literals, so the phrase never appears contiguously in the source. The sweep now joins adjacent literals before matching, which finds that one and no others. optionalInt is reachable only through CredentialAgeDays on CreateServiceSpecificCredential, so its case sits beside the test that already exercises that path and asserted only the error code. Two things deliberately left as they are. No snapshot in any service records a map *key* constraint, so the "Map keys must satisfy constraint: [...]" tail is a reasonable shape rather than an attested one, and the same goes for how a string-valued map spells its value path. The prefix is the attested part and the only part this changes. Not touched either: CloudWatch's recorded enum message names both the offending value and the permitted set, where IAM's omits both. That they differ is the point, and it is why #5239 changed only IAM's rendering. Refs #5240
This commit is contained in:
1 parent
9c2db353f1
commit
88d429a968
7 files changed
+94
-27
No files matched your search
@@ -903,9 +903,9 @@ public class IamQueryHandler {
|
||||
return Integer.valueOf(raw.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + raw + "' at '" + Character.toLowerCase(name.charAt(0))
|
||||
+ name.substring(1) + "' failed to satisfy constraint: Member must be "
|
||||
+ "an integer", 400);
|
||||
"1 validation error detected: Value '" + raw + "' at '"
|
||||
+ Character.toLowerCase(name.charAt(0)) + name.substring(1)
|
||||
+ "' failed to satisfy constraint: Member must be an integer", 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2913,7 +2913,8 @@ public class IamQueryHandler {
|
||||
String value = params.getFirst(name);
|
||||
if (value == null || value.isBlank()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value null at '" + Character.toLowerCase(name.charAt(0)) + name.substring(1)
|
||||
"1 validation error detected: Value null at '"
|
||||
+ Character.toLowerCase(name.charAt(0)) + name.substring(1)
|
||||
+ "' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -1419,8 +1419,9 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
&& !"AWS".equalsIgnoreCase(scope)
|
||||
&& !"Local".equalsIgnoreCase(scope)) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + scope + "' at 'scope' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: [All, AWS, Local]", 400);
|
||||
"1 validation error detected: Value '" + scope + "' at 'scope' failed to "
|
||||
+ "satisfy constraint: Member must satisfy enum value set: "
|
||||
+ "[All, AWS, Local]", 400);
|
||||
}
|
||||
String prefix = pathPrefix != null ? pathPrefix : "/";
|
||||
boolean blankScope = scope == null || scope.isBlank();
|
||||
@@ -2327,8 +2328,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
public void putAccountProperties(Map<String, String> properties) {
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value null at 'properties' failed to satisfy constraint: Member must not be "
|
||||
+ "null", 400);
|
||||
"1 validation error detected: Value null at 'properties' failed to "
|
||||
+ "satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
String namespace = null;
|
||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
||||
@@ -2365,7 +2366,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
if (key == null || key.isEmpty() || key.length() > MAX_ACCOUNT_PROPERTY_KEY_LENGTH
|
||||
|| !ACCOUNT_PROPERTY_KEY_PATTERN.matcher(key).matches()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + key + "' at 'properties' failed to satisfy constraint: Map keys "
|
||||
"1 validation error detected: Value '" + key + "' at 'properties' failed "
|
||||
+ "to satisfy constraint: Map keys "
|
||||
+ "must satisfy constraint: [Member must have length less than or "
|
||||
+ "equal to " + MAX_ACCOUNT_PROPERTY_KEY_LENGTH + ", Member must "
|
||||
+ "satisfy regular expression pattern: "
|
||||
@@ -2385,9 +2387,9 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
if (value == null || value.isEmpty()
|
||||
|| value.length() > MAX_ACCOUNT_PROPERTY_VALUE_LENGTH) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value at 'properties." + key + "' failed to satisfy constraint: Member must "
|
||||
+ "have length between 1 and " + MAX_ACCOUNT_PROPERTY_VALUE_LENGTH,
|
||||
400);
|
||||
"1 validation error detected: Value at 'properties." + key + "' failed to "
|
||||
+ "satisfy constraint: Member must have length between 1 and "
|
||||
+ MAX_ACCOUNT_PROPERTY_VALUE_LENGTH, 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2396,8 +2398,9 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
if (globalEndpointTokenVersion == null
|
||||
|| !GLOBAL_ENDPOINT_TOKEN_VERSIONS.contains(globalEndpointTokenVersion)) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + globalEndpointTokenVersion + "' at 'globalEndpointTokenVersion' "
|
||||
+ "failed to satisfy constraint: Member must satisfy enum value set: ["
|
||||
"1 validation error detected: Value '" + globalEndpointTokenVersion
|
||||
+ "' at 'globalEndpointTokenVersion' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: ["
|
||||
+ String.join(", ", GLOBAL_ENDPOINT_TOKEN_VERSIONS) + "]", 400);
|
||||
}
|
||||
stsPreferences.put(STS_PREFERENCES_KEY, globalEndpointTokenVersion);
|
||||
@@ -3095,10 +3098,10 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
if (credentialAgeDays < MIN_CREDENTIAL_AGE_DAYS
|
||||
|| credentialAgeDays > MAX_CREDENTIAL_AGE_DAYS) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + credentialAgeDays + "' at 'credentialAgeDays' failed to "
|
||||
+ "satisfy constraint: Member must be between "
|
||||
+ MIN_CREDENTIAL_AGE_DAYS + " and " + MAX_CREDENTIAL_AGE_DAYS,
|
||||
400);
|
||||
"1 validation error detected: Value '" + credentialAgeDays
|
||||
+ "' at 'credentialAgeDays' failed to satisfy constraint: "
|
||||
+ "Member must be between " + MIN_CREDENTIAL_AGE_DAYS + " and "
|
||||
+ MAX_CREDENTIAL_AGE_DAYS, 400);
|
||||
}
|
||||
}
|
||||
synchronized (serviceCredentialLock) {
|
||||
|
||||
+3
-2
@@ -59,8 +59,9 @@ public class ServiceLastAccessedService {
|
||||
List<ServiceLastAccessedEntity> entities) {
|
||||
if (granularity != null && !GRANULARITIES.contains(granularity)) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Value '" + granularity + "' at 'granularity' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: [SERVICE_LEVEL, ACTION_LEVEL]", 400);
|
||||
"1 validation error detected: Value '" + granularity + "' at 'granularity' "
|
||||
+ "failed to satisfy constraint: Member must satisfy enum value set: "
|
||||
+ "[SERVICE_LEVEL, ACTION_LEVEL]", 400);
|
||||
}
|
||||
Instant now = Instant.now();
|
||||
// jobIDType is min 36 / max 36, which is exactly a UUID string.
|
||||
|
||||
Reference in new issue
Block a user