The error would be in input data, probably.
Can you please tell me here the “data” value whenever this error came (it would be easy to see in on which x error is coming)
or is this coming for all x or data values.
print the type of data and check.