Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected TypeError exception thrown by amanda during validation #69

Open
jkryl opened this issue Dec 3, 2013 · 1 comment
Open

unexpected TypeError exception thrown by amanda during validation #69

jkryl opened this issue Dec 3, 2013 · 1 comment

Comments

@jkryl
Copy link

jkryl commented Dec 3, 2013

Following exception stack is printed:

Uncaught exception: TypeError: Object.keys called on non-object, stack:
    at Function.keys (native)
    at keys (/root/nef/node_modules/amanda/releases/latest/amanda.js:334:17)
    at Object.additionalProperties (/root/nef/node_modules/amanda/releases/latest/amanda.js:472:22)
    at Validation.validateProperty.iterator (/root/nef/node_modules/amanda/releases/latest/amanda.js:1821:26)
    at Array.addToQueue [as 0] (/root/nef/node_modules/amanda/releases/latest/amanda.js:86:16)
    at asyncEach (/root/nef/node_modules/amanda/releases/latest/amanda.js:111:20)
    at each (/root/nef/node_modules/amanda/releases/latest/amanda.js:118:22)
    at Validation.validateProperty (/root/nef/node_modules/amanda/releases/latest/amanda.js:1840:10)
    at Validation.validateSchema (/root/nef/node_modules/amanda/releases/latest/amanda.js:1856:15)
    at Validation.validateItems (/root/nef/node_modules/amanda/releases/latest/amanda.js:1668:19)

when validating following data:

'tpool0/fs0'

according to following scheme:

{
    type: 'object',
    properties: {
        name: { type: 'string', required: true },
        id:   schemata.guid
    },
    additionalProperties: false
};

apparently the data are not valid, as data are plain string and according to schema object is expected nevertheless amanda should report error properly and it shouldn't throw uncaught exception. The problem is in additionalPropertiesAttribute(). Before the method tries to get object properties by keys(propertyValue) it should check if the value which it is operating on is indeed an object and if not it should bail out from the function. Something like this:

/**
 * AdditionalProperties
 */
var additionalPropertiesAttribute = function additionalProperties(property, propertyValue, attributeValue, propertyAttributes, callback) {

  var self = this;

  /**
   * {
   *   additionalProperties: true,
   *   ...
   * }
   */
  if (attributeValue === true) {
    return callback();
  }

  if (!isObject(propertyValue)) {
    return callback();
  }

  // Filter the forbidden properties
  var propertyKeys = keys(propertyValue);
 ...
@topaz1008
Copy link
Contributor

I've made a pull request which fixes this. #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants