I've seen this issue as well and it seems related to the backend system that is being used.
For example, the code worked when using on ArcGIS Online services, but when hitting client ArcGIS Server feature services, the error would occur. Same data, same code, different environments.
Only difference I tracked as that the backend system of the client was Oracle. Ended up having to just remove those parameters, but surely would be nice to figure out the issue.
The client services I access are private which is why I didn't purse it any further since I don't have data to share which can reproduce the issue.