Gi60s / openapi-enforcer

Apache License 2.0
94 stars 22 forks source link

Bug: Enforcer options object is altered #74

Closed Lakitna closed 4 years ago

Lakitna commented 4 years ago

This seems to be an issue since this line was changed.

When running the enforcer multiple times with the same options object the second pass will throw an error:

options.exceptionSkipCodes.reduce is not a function

What seems to happen is that in the first pass options.exceptionSkipCodes is changed from an array to an object. This change is a side effect that causes the error to be thrown on the second pass where it essentially tries to do {}.reduce() instead of [].reduce().

It looks like the same side effect is created for options.exceptionEscalateCodes on this line

I've solved this for now by cloning my options object before passing it to the enforcer.

Gi60s commented 4 years ago

Thanks for the bug report and awesome research identifying the problem. I've made a fix in 1.10.3 and have published it to NPM.