apigee / apigeelint

Static code analysis for Apigee proxy bundles to encourage API developers to use best practices and avoid anti-patterns.
Apache License 2.0
91 stars 71 forks source link

fix: do not call xpath.select() with non element #415

Closed DinoChiesa closed 7 months ago

DinoChiesa commented 7 months ago

In some cases, the tool called xpath.select() with an object that was not a DOM element. With v0.0.33 of the xpath module, the error was silently ignored. But with v0.0.34 of the xpath module, this caused an error message like so:

Error: Context node does not appear to be a valid DOM node.
    at XPath.evaluate (/Users/dchiesa/dev/apigeelint/node_modules/xpath/xpath.js:1359:19)
    at XPathExpression.evaluate (/Users/dchiesa/dev/apigeelint/node_modules/xpath/xpath.js:4536:33)
    at exports.selectWithResolver (/Users/dchiesa/dev/apigeelint/node_modules/xpath/xpath.js:4989:33)
    at exports.select (/Users/dchiesa/dev/apigeelint/node_modules/xpath/xpath.js:4969:24)
    at FlowPhase.getSteps (/Users/dchiesa/dev/apigeelint/lib/package/FlowPhase.js:50:21)
    at /Users/dchiesa/dev/apigeelint/lib/package/Endpoint.js:306:35
    at Array.forEach (<anonymous>)
    at /Users/dchiesa/dev/apigeelint/lib/package/Endpoint.js:304:17
    at Array.forEach (<anonymous>)
    at Endpoint.getSteps (/Users/dchiesa/dev/apigeelint/lib/package/Endpoint.js:299:8)

The primary cause was sloppy initialization of child fields in Endpoint.js.

The problem was exacerbated by

  1. a bug in the Flow.js module that treated all flows as sharedflows
  2. ignoring exceptions in some plugins