Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle cases where
ExpressionEvaluationDetails#targetValue
is not a…
…n array For single values the API might return with a single value instead of an array with one element. In that case the following error is produced: ``` com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token at [Source: (String)"{"policyDefinitionDisplayName":"Allowed resource types","policySetDefinitionDisplayName":"webapp","evaluationDetails":{"evaluatedExpressions":[{"result":"False","expression":"type","path":"type","expressionValue":"Microsoft.ApiManagement/service","targetValue":"Microsoft.Resources/resourceGroups","operator":"In"}]},"policyDefinitionId":"/providers/Microsoft.Authorization/policyDefinitions/a08ec900-254a-4555-9bf5-e42af04b5c5c","policySetDefinitionId":"/providers/Microsoft.Management/managementGro"[truncated 692 chars]; line: 1, column: 262] (through reference chain: com.microsoft.azure.CloudError["additionalInfo"]->java.util.ArrayList[1]->com.microsoft.azure.PolicyViolationErrorInfo["evaluationDetails"]->com.microsoft.azure.EvaluationDetails["evaluatedExpressions"]->java.util.ArrayList[0]->com.microsoft.azure.ExpressionEvaluationDetails["targetValue"]) at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1445) at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1219) at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1129) at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.handleNonArray(StringCollectionDeserializer.java:274) at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:183) at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:173) at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:21) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4218) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3214) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3182) at com.microsoft.azure.PolicyViolation.<init>(PolicyViolation.java:41) ``` eg: `"targetValue":"Microsoft.Resources/subscriptions/resourceGroups"` is received instead of `"targetValue":["Microsoft.Resources/subscriptions/resourceGroups"]` In this commit: - `@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)` is added to `ExpressionEvaluationDetails#targetValue` - verified by adjusting the unit test, which would fail without the fix
- Loading branch information