Project

General

Profile

Actions

Bug #3880

closed

headers passed into api should be cloned before modified

Added by Thomas McKay over 10 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

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.

Actions #1

Updated by Dominic Cleal over 10 years ago

  • 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.

Actions #2

Updated by Thomas McKay over 10 years ago

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.

Actions #3

Updated by Dominic Cleal over 10 years ago

  • Category changed from API to 65
  • Status changed from Need more information to Assigned
  • Assignee set to Martin Bacovsky

Gotcha, thanks.

Actions #4

Updated by Tomer Brisker over 9 years ago

  • Status changed from Assigned to New
Actions #5

Updated by Tomer Brisker over 5 years ago

  • Category changed from 65 to API
Actions #6

Updated by Leos Stejskal almost 3 years ago

  • 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.

Actions

Also available in: Atom PDF