core: only recurse relevant request objects#2100
core: only recurse relevant request objects#2100stephenplusplus merged 1 commit intogoogleapis:masterfrom
Conversation
|
LGTM - my only request would be to add a (probably system) test that passes in something with a circular reference. |
|
That's a fair request, but hopefully you can help me figure out the right way to handle this, because it might be more complex than it seems at first glance. The error reported from #1908 is indeed from a recursion issue. And this PR does fix it, but not by handling the circular reference directly, but by narrowing the scope of the input to these properties that we loop over. In effect, that addresses the circular reference, because we aren't looping over unknown values on the But, the project ID token could be alongside user input, and that user input could have a circular reference, and when we iterate over it looking for the project ID token, the code would blow up the same way as in #1908. The complicated part is, each API-- or even, each method-- could have its own preferred way of handling circular references-- maybe it's okay, maybe it should be replaced with So, the question is-- do we handle circular references, and if so, how? |
Fixes #1908
Previously, we took an input object that would go to
requestand iterated over all of the properties. This turned out to be an issue when the request object had properties containing circular references. What we really want to do is loop a select number of properties which may include the projectId token:reqOpts.qs(an object which gets serialized into a query string)reqOpts.json(the JSON payload)reqOpts.uri(the URL the request is sent to, which always exists)