deliveryhero / serverless-aws-documentation

Serverless 1.0 plugin to add documentation and models to the serverless generated API Gateway
MIT License
309 stars 148 forks source link

Abortion in getDocumentationVersion that ends up in 'Invalid Documentation version specified'. #173

Open bdoin opened 3 years ago

bdoin commented 3 years ago

When AWS getDocumentationVersion is called and that there is no existing version for the API, the error catching is not performed properly and ends up in the error: 'Invalid Documentation version specified'

Not sure but this maybe due to a difference in the way serverless manages the error when calling AWS API.

Now the proper way to handle this is to test (err.providerError && err.providerError.code === 'NotFoundException')) instead of testing err.message === 'Invalid Documentation version specified'.

rojanawi-droople commented 3 years ago

Thanks for the fix!

ottopecz commented 3 years ago

The actual error object thrown by the serverless aws provider has changed in the newer versions.

The message of the thrown error has become longer although it includes the string 'Invalid Documentation version specified'

When expecting an error it's better to rely on something more abstract and formal than the message of the error. Good choices might include the code or the statusCode

We published a fix and we plan to maintain the package. https://www.npmjs.com/package/@kakkuk/serverless-aws-apigateway-documentation