InterNetX / js-domainrobot-sdk

A javascript package for easy integration of the Domainrobot API powered by InterNetX GmbH.
MIT License
10 stars 7 forks source link

api and/or DomainRobotResult on Zone-Updates broken #3

Closed mashpie closed 4 years ago

mashpie commented 4 years ago

Debugged a recent wired behaviour: Zone-Updates return with exception 500 "TypeError: Cannot read property 'data' of undefined" but the update got committed to DNS Server.

DomainRobotResult returns invalid at https://github.com/InterNetX/js-domainrobot-sdk/blob/master/src/lib/DomainRobotResult.js#L12

because returned payload does not include any data property at top level (but at object.data):

{
  stid: '20200315-app2-158665',
  status: {
    code: 'S0202',
    text: 'Zone wurde erfolgreich auf dem Nameserver aktualisiert.',
    type: 'SUCCESS'
  },
  object: {
    type: 'Zone',
    value: 'dummy-vhost.com',
    data: {
      origin: 'dummy-vhost.com',
      virtualNameServer: 'a.ns14.net',
      roid: 5163193
    }
  }
}

reproduced workflow

GET https://api.autodns.com/v1/zone/dummy-vhost.com/a.ns14.net

returns 200 correctly:

{
  stid: '20200315-app1-144341',
  status: {
    code: 'S0205',
    text: 'Zonen-Informationen wurden erfolgreich ermittelt.',
    type: 'SUCCESS'
  },
  object: { type: 'Zone', value: 'dummy-vhost.com' },
  data: [
    {
      created: '2012-06-28T14:12:06.000+0200',
      updated: '2020-03-03T15:12:06.000+0100',
      origin: 'dummy-vhost.com',
      soa: [Object],
      owner: [Object],
      updater: [Object],
      nameServers: [Array],
      main: [Object],
      wwwInclude: true,
      virtualNameServer: 'a.ns14.net',
      action: 'COMPLETE',
      resourceRecords: [Array],
      roid: 5163193
    }
  ]
}

next let's try an update:

PUT https://api.autodns.com/v1/zone/dummy-vhost.com/a.ns14.net 

with payload of:

model {
  created: '2012-06-28T14:12:06.000+0200',
  updated: '2020-03-03T15:12:06.000+0100',
  origin: 'dummy-vhost.com',
  idn: undefined,
  soa: model {
    refresh: 43200,
    retry: 14400,
    expire: 604800,
    ttl: 86400,
    email: 'domains@uscreen.net'
  },
  dnssec: undefined,
  nameServerGroup: undefined,
  allowTransfer: undefined,
  owner: model { context: 4, user: '**********' },
  updater: model { context: 4, user: '**********' },
  logId: undefined,
  comment: undefined,
  domainsafe: undefined,
  source: undefined,
  sourceVirtualHostname: undefined,
  nameServers: [
    model {
      name: 'a.ns14.net',
      ttl: undefined,
      ipAddresses: undefined
    },
    model {
      name: 'b.ns14.net',
      ttl: undefined,
      ipAddresses: undefined
    },
    model {
      name: 'c.ns14.net',
      ttl: undefined,
      ipAddresses: undefined
    },
    model {
      name: 'd.ns14.net',
      ttl: undefined,
      ipAddresses: undefined
    }
  ],
  main: model { address: '37.130.139.3', ttl: undefined },
  wwwInclude: true,
  virtualNameServer: 'a.ns14.net',
  freeText: undefined,
  action: 'COMPLETE',
  grants: undefined,
  resourceRecords: [
    model {
      name: '',
      ttl: undefined,
      type: 'MX',
      value: 'mx.uscreen.net.',
      pref: 10
    }
  ],
  roid: 5163193
}

also return with 200, but aims to be inValid:

{
  stid: '20200315-app2-158665',
  status: {
    code: 'S0202',
    text: 'Zone wurde erfolgreich auf dem Nameserver aktualisiert.',
    type: 'SUCCESS'
  },
  object: {
    type: 'Zone',
    value: 'dummy-vhost.com',
    data: {
      origin: 'dummy-vhost.com',
      virtualNameServer: 'a.ns14.net',
      roid: 5163193
    }
  }
} 

which results in Exception:

TypeError: Cannot read property 'data' of undefined
    at Zone.sendRequest (**truncated**/node_modules/js-domainrobot-sdk/src/services/DomainRobotService.js:85:24)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Zone.update (**truncated**/node_modules/js-domainrobot-sdk/src/services/ZoneService.js:17:12)
    at async Object.<anonymous> (**truncated**/app/services/zones.js:39:22)

Ok, easy to catch - but still SDK won't return any valid result on such an update request. Can't tell whether api itself or DomainRobotResultis misbehaving. So please, could you check to review?

adelholtz commented 4 years ago

Hi

thank you for reporting this issue. We have adjusted the validation check for API results inside the DomainRobot SDK which have been to strict for some cases/results resulting in the error you reported above. The behaviour of the SDK should be as expected om Version 0.2.2.

Have a nice day!

mashpie commented 4 years ago

perfect thanks! I can confirm it's working :)

stay healthy!