Skip to content

'in' operator is less robust than other options for deriving key presence  #440

@Packmanager9

Description

@Packmanager9

Problem:
Given that the 'in' operator will throw an error error and fail: 'Cannot use 'in' operator to search for 'top' in 1'
(Line 4959 in 'msRest.node.js)

Solution
A different method of deriving the key presence could be used.

Original:

  if (parent != undefined && parameterPathPart in parent) {
      parent = parent[parameterPathPart];
  }

Proposed:

  if (parent != undefined && Object.keys(parent).includes(parameterPathPart)) {
      parent = parent[parameterPathPart];
  } 

Alternatives:
Tried removing the check all together, immediately fails.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions