Skip to content

Array with null elements crashes program #33

Description

@JonathanWilbur

xml({ foo: null }) works fine, but xml({ bar: [ null, null ] }) causes the program to crash. I know it seems like an edge case, but I am converting a JSON document from a database query and some documents contain arrays with null elements.

Here is the stack trace:

events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot convert undefined or null to object
at /x/node_modules/xml/lib/xml.js:185:44
at Array.forEach (native)
at resolve (/x/node_modules/xml/lib/xml.js:183:24)
at add (/x/node_modules/xml/lib/xml.js:47:24)
at xml (/x/node_modules/xml/lib/xml.js:89:9)
at [REDACTED]
at Query. (/x/node_modules/mongoose/lib/model.js:3340:16)
at /x/node_modules/kareem/index.js:259:21
at /x/node_modules/kareem/index.js:127:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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