The problem is that URLQueryItem claims to handle the encoding. So you're encoding twice in some cases by also using addingPercentEncoding.
The other problem is that URLQueryItem doesn't really know how to encode HTTP parameters. For example, forward slashes are passed straight through, instead of encoding to %2F.
At some point you give up and just do it yourself from the spec.