Provoking an error in alexa ask deployment sometimes results in an error in the getAskError function.
Example:
Using a non existent ask profile like so:
new AlexaCli({askProfile: 'does-not-exist', locales: {en: ['en-US']}})
This leads to the stderr:
Command failed: ask smapi create-upload-url -p does-not-exist
Debugger listening on ws://127.0.0.1:42595/25792652-dbcc-412d-bf9d-4db5fcbd8620
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Debugger listening on ws://127.0.0.1:39601/8953403c-efec-4e66-a3c0-89661f15f337
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
[Error]: Can't resolve profile [does-not-exist] as it doesn't exist. Please run "ask configure --profile does-not-exist" first.
The current version of getAskError tries to parse the substring after [Error], in this case this text Can't resolve profile [does-not-exist] as it doesn't exist. Please run "ask configure --profile does-not-exist" first.. As this clearly is no JSON object/array. This JSON.parse throws an error resulting in this being displayed after running jovo deploy:platform alexa:
🚀 Deploying Alexa Skill
✖ Uploading skill package
x Error: --------------------------------------------------------------------------------
›
› Message:
› Unexpected token C in JSON at position 0
›
› Module:
› JovoCliCore
›
›
› If you think this is not on you, you can submit an issue here: https://github.com/jovotech/jovo-cli/issues.
This is why I built a block to catch the error from JSON.parse, which creates the JovoCliError in a different way, leading to the actual helpful error message being displayed after running the jovo deploy, in this case:
🚀 Deploying Alexa Skill
✖ Uploading skill package
x Error: --------------------------------------------------------------------------------
›
› Message:
› smapiCreateUploadUrl: Can't resolve profile [does-not-exist] as it doesn't exist. Please run "ask configure --profile does-not-exist" first.
›
›
› Module:
› AlexaCli
›
›
› If you think this is not on you, you can submit an issue here: https://github.com/jovotech/jovo-cli/issues.
As this further increased the size of the function I also refactored some logic into its own function getViolation to improve readability.
Types of Changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
[x] My code follows the code style of this project
[x] My change requires a change to the documentation
Proposed Changes
Provoking an error in alexa ask deployment sometimes results in an error in the
getAskError
function.Example: Using a non existent ask profile like so:
This leads to the
stderr
:The current version of
getAskError
tries to parse the substring after[Error]
, in this case this textCan't resolve profile [does-not-exist] as it doesn't exist. Please run "ask configure --profile does-not-exist" first.
. As this clearly is no JSON object/array. ThisJSON.parse
throws an error resulting in this being displayed after runningjovo deploy:platform alexa
:This is why I built a block to catch the error from
JSON.parse
, which creates theJovoCliError
in a different way, leading to the actual helpful error message being displayed after running the jovo deploy, in this case:As this further increased the size of the function I also refactored some logic into its own function
getViolation
to improve readability.Types of Changes
Checklist