Skip to content

Error: Cannot read property 'split' of undefined #1

@henrinormak

Description

@henrinormak

With nested functions/definitions, an error occurs when the inner value is not defined on the parameters/payload.

Minimal example that causes this problem:

var mappingTemplate = require('api-gateway-mapping-template');

var template = '$util.escapeJavaScript($input.params(\'test\'))';

var params = {
    header: {},
    querystring: {},
    path: {}
};
var payload = '';

var result = mappingTemplate({
    template: template,
    params: params
    payload: payload
});

// Results in error similar to
// Error: Cannot read property 'split' of undefined on $util.escapeJavaScript($input.params('test')) at L/N 1:0

Expected behavior (and as far as I understand, what API Gateway would actually do) is to resolve this to be completely undefined, meaning calls to util functions with an undefined parameter results in an undefined value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions