Hello
I have noticed a breaking change in the Python SDK since version 142.0.0
. The thing is that now there are some class property setters that include a validation for not allowing empty values. I think this was not included in the SDK Release Notes.
Before that change, I used to set some properties as empty lists, and then I filled them with the proper values. Now, that is not possible, as it throws an error. For example, this code:
import PureCloudPlatformClientV2 as sdk
clause = sdk.SegmentDetailQueryClause()
clause.type = 'or'
clause.predicates = []
for i in range(3): # example loop
predicate = sdk.SegmentDetailQueryPredicate()
# ... fill the predicate properties
clause.predicates.append(predicate)
works fine in versions <142.0.0
, but in >=142.0.0
it throws
ValueError: Invalid value for `predicates`, must not be `None`
It does so because the validation in the setter is:
if not predicates:
raise ValueError("Invalid value for `predicates`, must not be `None`")
That checks if predicates
is falsy, not just None
. So, to the fixed version for the previous code would be something like:
import PureCloudPlatformClientV2 as sdk
clause = sdk.SegmentDetailQueryClause()
clause.type = 'or'
clause_predicates = [] # use a helper variable
for i in range(3): # example loop
predicate = sdk.SegmentDetailQueryPredicate()
# ... fill the predicate properties
clause_predicates.append(predicate)
clause.predicates = clause_predicates
or
import PureCloudPlatformClientV2 as sdk
clause = sdk.SegmentDetailQueryClause()
clause.type = 'or'
clause.predicates = [None] # fill it with one dummy item
for i in range(3): # example loop
predicate = sdk.SegmentDetailQueryPredicate()
# ... fill the predicate properties
clause.predicates.append(predicate)
clause.predicates.remove(None) # remove dummy item
Those look quite ugly to me. Therefore, I would like to suggest allowing empty lists as property values.