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

internal.computeValue() throws if keys is not present under certain circumstances #65

Closed
saadtazi opened this issue Sep 8, 2017 · 1 comment
Labels

Comments

@saadtazi
Copy link
Contributor

saadtazi commented Sep 8, 2017

Repro step:

// this works
mingo._internal().computeValue({l1: {l2: [{l3: [{ a: 666}]}]}}, '$l1.l2.l3.a');

// this throws an exception
mingo._internal().computeValue({l1: {l2: [{l3: [{ a: 666}]}, {l4: 'some prop'}]}}, '$l1.l2.l3.a');

Thrown exception:

TypeError: Cannot read property 'a' of undefined
    at getValue (path/to/project/node_modules/mingo/dist/mingo.js:3545:13)
    at _loop (path/to/project/node_modules/mingo/dist/mingo.js:3617:15)
    at resolve (path/to/project/node_modules/mingo/dist/mingo.js:3625:16)
    at path/to/project/node_modules/mingo/dist/mingo.js:3605:16
    at Array.map (native)
    at _loop (path/to/project/node_modules/mingo/dist/mingo.js:3604:21)
    at resolve (path/to/project/node_modules/mingo/dist/mingo.js:3625:16)
    at Object.computeValue (path/to/project/node_modules/mingo/dist/mingo.js:3840:12)
    at repl:1:19
    at sigintHandlersWrap (vm.js:22:35)

It seems like computeValue is trying to find a property a in 'some prop'.

@kofrasa kofrasa added the bug label Sep 8, 2017
@kofrasa
Copy link
Owner

kofrasa commented Sep 8, 2017

Thanks for the report.

Looks like a validation bug in the resolve() function most likely from not returning early given null or undefined input.

Maybe you can take a stab at this too if you are keen.

kofrasa added a commit that referenced this issue Sep 9, 2017
* filter out empty values from collection. fix #65
* correct NaN comparison in unit tests. fixes #66
* fix tests for $substrCP
* fix $substrBytes
* fix comparison operators by type checkin
kofrasa added a commit that referenced this issue Sep 9, 2017
* filter out empty values from collection. fix #65
* correct NaN comparison in unit tests. fixes #66
* fix tests for $substrCP
* fix $substrBytes
* fix comparison operators by type checkin
@kofrasa kofrasa closed this as completed in 1a66f12 Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants