Bug #3880
closed
headers passed into api should be cloned before modified
Added by Thomas McKay almost 11 years ago.
Updated over 3 years ago.
Description
The headers passed into api calls such as index(), create(), etc. take two args, params and headers. The headers passed in are modified during the api call to include the params which lead to errors in my program. We should clone the the hash before modifying it to avoid this potentially confusing behavior to the consumer of the api.
- Status changed from New to Need more information
Sorry, can you elaborate on this please? I don't follow what you mean from the issue description. Pointers to code might help.
Dominic Cleal wrote:
Sorry, can you elaborate on this please? I don't follow what you mean from the issue description. Pointers to code might help.
https://github.com/theforeman/foreman_api/blob/master/lib/foreman_api/base.rb?source=cc#L55
Note that http_call() takes in headers arg and then modifies it by adding the params.
In my case, I had defined a variable HEADERS that I was re-using by passing into the various api calls (.index, .create, .update, etc.). However, this variable was, incorrectly imo, being modified by the api calls due to above code.
- Category changed from API to 65
- Status changed from Need more information to Assigned
- Assignee set to Martin Bacovsky
- Status changed from Assigned to New
- Category changed from 65 to API
- Status changed from New to Closed
Hi, I'm closing the issue, it has been here for some time and I wasn't able to reproduce it on the latest version.
If you think that the issue is still relevant feel free to reopen it.
Also available in: Atom
PDF