You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
ModalLocationSchema validates that all location sub-queries have the same aggregation unit. However, a validation error in one of the sub-queries will result in the ModalLocationSchema validator attempting to access a non-existent 'aggregation_unit' attribute, and consequently raising an AttributeError instead of ValidationError.
This error message is misleading, as the aggregation unit is not the source of the issue. Also, as the error raised is an AttributeError, not ValidationError, this will result in the server failing to respond to FlowAPI, so a FlowClient user would see a generic "Could not get reply for message" 400 error instead of a helpful message with details of the invalid field.
Product
Flowmachine
To Reproduce
>>>params= {
'query_kind': 'modal_location',
'locations': [
{
'query_kind': 'daily_location',
'date': '2016-02-10',
'aggregation_unit': 'admin3',
'method': 'invalid-method',
}
]
}
>>>DailyLocationSchema().load(params["locations"][0])
ValidationError: {'method': ['Must be one of: last, most-common.']}
>>>ModalLocationSchema().load(params)
AttributeError: 'list'objecthasnoattribute'aggregation_unit'
Expected behavior
Attempting to specify an invalid daily location query as input to a modal location should raise a validation error identifying the invalid parameter.
Additional context
ModalLocationSchema is not the only schema that validates aggregation units in this way - other schemas are likely affected by the same issue.
The text was updated successfully, but these errors were encountered:
Describe the bug
ModalLocationSchema validates that all location sub-queries have the same aggregation unit. However, a validation error in one of the sub-queries will result in the ModalLocationSchema validator attempting to access a non-existent 'aggregation_unit' attribute, and consequently raising an
AttributeError
instead ofValidationError
.This error message is misleading, as the aggregation unit is not the source of the issue. Also, as the error raised is an
AttributeError
, notValidationError
, this will result in the server failing to respond to FlowAPI, so a FlowClient user would see a generic "Could not get reply for message" 400 error instead of a helpful message with details of the invalid field.Product
Flowmachine
To Reproduce
Expected behavior
Attempting to specify an invalid daily location query as input to a modal location should raise a validation error identifying the invalid parameter.
Additional context
ModalLocationSchema is not the only schema that validates aggregation units in this way - other schemas are likely affected by the same issue.
The text was updated successfully, but these errors were encountered: