ipaddress-gem/ipaddress

ipaddress gem breaks aws-sdk RESTXMLClient

Closed this issue · 6 comments

garo commented

ipaddress is used with the Chef Ohai component, which caused a really bizarre problem: When aws-sdk (1.51.0, the newest atm) is used to do a create_health_check request it can't correctly send xml property named "IPAddress" to the aws api.

How to reproduce with irb:

require 'ipaddress'
require 'aws-sdk'
r53 = AWS::Route53.new(:access_key_id => "....",:secret_access_key => "...",:http_wire_trace => true)
options = {:caller_reference => "foo",:health_check_config => {:ip_address => "54.84.217.101",:type => "HTTP",:resource_path => "/check"}}
r53.client.create_health_check(options)

This prints that the following data is sent to the api:
"<CreateHealthCheckRequest xmlns=\"https://route53.amazonaws.com/doc/2013-04-01/\">\n <CallerReference>foo</CallerReference>\n <HealthCheckConfig>\n <Type>HTTP</Type>\n <ResourcePath>/check</ResourcePath>\n </HealthCheckConfig>\n</CreateHealthCheckRequest>"
(notice that there's no <IPAddress>54.84.217.101</IPAddress> tag)

Now another irb session without ipaddress gem:

require 'aws-sdk'
r53 = AWS::Route53.new(:access_key_id => "....",:secret_access_key => "...",:http_wire_trace => true)
options = {:caller_reference => "foo",:health_check_config => {:ip_address => "54.84.217.101",:type => "HTTP",:resource_path => "/check"}}
r53.client.create_health_check(options)

prints:
"<CreateHealthCheckRequest xmlns=\"https://route53.amazonaws.com/doc/2013-04-01/\">\n <CallerReference>foo</CallerReference>\n <HealthCheckConfig>\n <IPAddress>54.84.217.101</IPAddress>\n <Type>HTTP</Type>\n <ResourcePath>/check</ResourcePath>\n </HealthCheckConfig>\n</CreateHealthCheckRequest>"

So the ipaddress module is somehow monkey-patching something which breaks the aws-cli. the aws-cli builds the requests based on a yaml config which maps ruby property names into xml tags. Editing this yml and replacing the "IPAddress" tag definition with another name, say "IPAddress2" will result that the tag is rendered correctly.

There's at least one other user who was struct with this very same bug: https://forums.aws.amazon.com/thread.jspa?threadID=128785

garo commented

Unfortunately the reproduction needs AWS access keys which I can't obviously give here :(

Thanks for the bug report. One of the goals of IPAddress 1.0 is to remove all monkey patching. There's not much but I definitely want to clean up the code.

I'll let you know when master is updated so you can check if the bug is still there.

@garo can you confirm if this happens with AWS-SDK v2 which was released last month?

This one will be tricky. There is no sandbox env for Route53, so the only way to test API calls is to purchase a subscription, etc.

I was hoping to use pry to get the http request sent from the sdk to the server to see exactly where the issue originates from. What Ruby version are you using, 1.8 by any chance?

@bluemonk The monkey-patching you are mentioning here, is that something you want to add to the 1.0 checklist?

I've added a meta issue where we can track things we want to fix before 1.0:
#132

I think this may be the monkey patch causing this: #140

It's on it's way out. Closing this issue. Let me know if you don't think this is the fix.