ovh / node-ovh

Node.js wrapper for the OVH APIs
http://ovh.github.io/node-ovh
Other
129 stars 27 forks source link

Library treats parameters equal to 0 as null and does not send them #14

Closed DSpeichert closed 8 years ago

DSpeichert commented 8 years ago

I am executing the following call in order to add a firewall rule on the IP:

await ovh.requestPromised('POST', '/ip/' + encodeURIComponent(ipblock) + '/firewall/' + ip + '/rule', ruleObj);

Consider the following ruleObj:

ruleObj = {
    action: 'permit',
    destinationPort: null,
    protocol: 'udp',
    sequence: 0,
    source: '8.8.8.8/32',
    sourcePort: 53,
    tcpOption: null
};

This will fail with error: error=400, message=Missing sequence parameter while calling creation handler

However, when I use the following, it works!:

ruleObj = {
    action: 'permit',
    destinationPort: null,
    protocol: 'udp',
    sequence: new String(0),
    source: '8.8.8.8/32',
    sourcePort: 53,
    tcpOption: null
};

It seems like the ovh library is treating numeric 0 as null and not sending it, while a String of 0 is properly sent. Other numbers work as expected when sent as Numbers.

bnjjj commented 8 years ago

Thanks for your report ! I'll check that next week ! And keep you update

bnjjj commented 8 years ago

It's done in v2.0.1. Let me know if it's right for you too ! Thank you