jovotech / jovo-cli

🛠 Command Line Interface for the Jovo Framework: Makes voice experience deployment a breeze, including features like local development and staging.
https://www.jovo.tech/marketplace/jovo-cli
Apache License 2.0
57 stars 31 forks source link

Unable to deploy alexa skill #357

Closed subha-aws closed 1 year ago

subha-aws commented 1 year ago

I'm submitting a...

I created the sample app via jovo new . After some config changes, It builds and also runs locally

Expected Behavior

Deploy to default alexa profile

Current Behavior

It errors with cannot find headers.find

Error log

jovo deploy:platform: Deploy to the specified platform's developer console

Learn more: https://jovo.tech/docs/deploy-command#deploy-platform

(node:12240) Warning: Accessing non-existent property 'defaultStage' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) Deploying Alexa Skill ✖ Uploading skill package

x Error: -------------------------------------------------------------------------------- › › Message: › headers.find is not a function › › Module: › JovoCliCore › › › Stack: › Error: headers.find is not a function › at Task.run (D:\Users\username\Documents\code\src\healthskill\node_modules\@jovotech\cli-core\src\Task.ts:111:17) › at Task.run (D:\Users\username\Documents\code\src\healthskill\node_modules\@jovotech\cli-core\src\Task.ts:66:9) › at AlexaHook.deploy (D:\Users\username\Documents\code\src\healthskill\node_modules\@jovotech\platform-alexa\src\cli\hooks\DeployHook.ts:227:5) › at EventEmitter.run (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@jovotech\cli-core\src\EventEmitter.ts:53:7) › at DeployPlatform.run (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@jovotech\cli-command-deploy\src\commands\deploy.platform.ts:100:5) › at DeployPlatform._run (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@oclif\command\lib\command.js:43:20) › at Config.runCommand (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@oclif\config\lib\config.js:173:24)
› at Main.run (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@oclif\command\lib\main.js:28:9) › at Main._run (D:\Users\username\AppData\Roaming\npm\node_modules\@jovotech\cli\node_modules\@oclif\command\lib\command.js:43:20) › › If you think this is not on you, you can submit an issue here: https://github.com/jovotech/jovo-cli/issues.

Your Environment

Windows VSCode

Jovo packages of the current project (updates available):

anneleenscholts commented 1 year ago

I think I found the issue with this in the library code. Can I open a PR for this?

alep-anoki commented 1 year ago

I have the same problem.

bsene commented 1 year ago

same here , would be fine if someone is working on to fix this

jrglg commented 1 year ago

Hi @alep-anoki @bsene @anneleenscholts @subha-aws I posted a solution here https://github.com/jovotech/jovo-framework/issues/1568#issuecomment-1640486302

The fix is here https://github.com/jovotech/jovo-framework/pull/1575

If you can't wait and you are not in CICD you can modifiy the .js file in your project node_modules:

\node_modules\@jovotech\platform-alexa\dist\cjs\cli\smapi\SkillPackageManagement.js

function parseImportUrl({ headers }) {
    const headersArray = Object.entries(headers);
    const locationHeader = headersArray.find(([key]) => key === 'location');

    if (locationHeader) {
      const [, value] = locationHeader;
      return value.split('/').pop();
    }

    return undefined;
  }
bsene commented 1 year ago

Great! thanks you @jrglg hope it will be merged soon

ilovelinux commented 1 year ago

This error happened because of an unreported breaking change in ask-cli 2.30.0 caused by commit https://github.com/alexa/ask-cli/commit/fd20898d6d87cf30ce4dc3e7a78434aac531929b

We should require an ask-cli version equal to or newer than v2.30.0 after the fix.

OLD Headers format until ask-cli 2.29.2:

[
  { "key": "content-type", "value": "application/json" },
  { "key": "content-length", "value": "2" },
  { "key": "connection", "value": "keep-alive" },
  { "key": "server", "value": "Server" },
  { "key": "date", "value": "Thu, 01 Jan 1970 00:00:00 GMT" },
  { "key": "x-amz-rid", "value": "XXXXXXXXXXXXXXXXXXXXXX" },
  { "key": "x-amzn-requestid", "value": "XXXXXXXXXXXXXXXXXXXXXX" },
  { "key": "x-amz-date", "value": "Thu, 01 Jan 1970 00:00:00 GMT" },
  { "key": "location", "value": "/v1/skills/imports/amzn1.ask-package.import.XXXXXXXXXXXXXXXXXXXXXX" },
  { "key": "vary", "value": "Content-Type,Accept-Encoding,User-Agent" },
  { "key": "strict-transport-security", "value": "max-age=47474747; includeSubDomains; preload" },
  { "key": "x-cache", "value": "Miss from cloudfront" },
  { "key": "via", "value": "1.1 XXXXXXXXXXXXXXXXXXXXXX.cloudfront.net (CloudFront)" },
  { "key": "x-amz-cf-pop", "value": "XXXXX-XX" },
  { "key": "x-amz-cf-id", "value": "XXXXXXXXXXXXXXXXXXXXXX" }
]

NEW Headers format since ask-cli 2.30.0:

{
  "content-type": "application/json",
  "content-length": "2",
  "connection": "keep-alive",
  "server": "Server",
  "date": "Thu, 01 Jan 1970 00:00:00 GMT",
  "x-amz-rid": "XXXXXXXXXXXXXXXXXXXXXX",
  "x-amzn-requestid": "XXXXXXXXXXXXXXXXXXXXXX",
  "x-amz-date": "Thu, 01 Jan 1970 00:00:00 GMT",
  "location": "/v1/skills/imports/amzn1.ask-package.import.XXXXXXXXXXXXXXXXXXXXXX",
  "vary": "Content-Type,Accept-Encoding,User-Agent",
  "strict-transport-security": "max-age=47474747; includeSubDomains; preload",
  "x-cache": "Miss from cloudfront",
  "via": "1.1 XXXXXXXXXXXXXXXXXXXXXX.cloudfront.net (CloudFront)",
  "x-amz-cf-pop": "XXXXX-XX",
  "x-amz-cf-id": "XXXXXXXXXXXXXXXXXXXXXX"
}
ilovelinux commented 1 year ago

I forgot to mention the workaround!

Since the latest ask-cli supported version is 2.29.2, downgrading the tool is enough:

$ npm install -g ask-cli@2.29.2

After that, Alexa deploy should be working again.

aswetlow commented 1 year ago

It is fixed now.

Thank you for the workaround and the PR @ilovelinux