static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

swa deploy: App without swa config file declaring platform api runtime aborts and fails without printing error info

Open anfibiacreativa opened this issue 2 years ago • 7 comments

Before filing this issue, please ensure you're using the latest CLI by running swa --version and comparing to the latest version on npm.

Are you accessing the CLI from the default port :4280 ?

  • [ ] No, I am using a different port number (--port) and accessing the CLI from that port
  • [x] Yes, I am accessing the CLI from port :4280

Make sure you are accessing the URL printed in the console when running swa start!

ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug Angular app with managed API, need to have a configuration file with the following information { "platform": { "apiRuntime": "node:XX" } }

or deployment stage fails without error being displayed. This should have blocker priority, because there is absolutely no indication of cause of error that the developer can intuitively fix on their own.

Screen Shot 2022-10-28 at 5 39 18 PM

When running with verbose, we have more information, additionally referring to the lack of a config.file, although it's not marked as error but warning and you cannot infer the build fails for that reason.

Screen Shot 2022-10-28 at 5 42 46 PM

To Reproduce 1 - create an angular app with Angular CLI 2 - create an HTTP trigger function under ./api with func CLI 3- create a service for the app to request the endpoint 4 - test locally with swa CLI (swa + swa start) 5 - execute swa deploy. The deploy will begin and abruptly abort without error in log after the message deploying to preview.

Expected behavior At minimum the CLI should display output information explaining that a configuration file with platform.apiRuntime config should be created by the user, and a link to documentation.

Ideally, the platform should auto-detect the runtime version and spare the user from having to configure and maintain this configuration file on their own, to configure an item required by the system and not the app.

Screenshots Already provided.

Desktop (please complete the following information):

  • OS Monterey 12.6
  • SWA CLI 1.0.3
  • Angular 14.0.2
  • Node v16.16.0
  • npm version 8.11.0

Additional context Add any other context about the problem here.

anfibiacreativa avatar Oct 28 '22 15:10 anfibiacreativa

Thanks for reporting this @anfibiacreativa, we should definitely provide better logs/auto-detection to help guide the experience. For context for others reading, this is related to the requirement that the api runtime needs to be configured in staticwebapp.config.json as documented here: https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deploy-a-front-end-app-with-an-api

thomasgauvin avatar Oct 28 '22 16:10 thomasgauvin

Thanks for your response. I know it's documented but I really feel we can improve the experience by automating detection, or at least indicating users what the problem is, while deploying.

anfibiacreativa avatar Oct 28 '22 17:10 anfibiacreativa

Hey @anfibiacreativa , thanks for reporting this. Although the issue is known as you mentioned there is no indication of the error in the logs which is a painful experience for the user. To fix this, there are two active tasks we're working on

  1. There is an active PR which addresses the last problem you mentioned by automatically detecting the function language.
  2. We're working on adding more logs in the StaticSiteClient thereby providing user more context over the problem.

sgollapudi77 avatar Oct 29 '22 05:10 sgollapudi77

Hi @sgollapudi77, Is this issue applicable if the application does not have an API? The ticket I raised #608 was closed as a duplicate of this one, but I don't have an API in my application, only a bunch of static assets. Also, the output from the CLI that starts with "API Directory Location" in the screenshot above was not printed in my case.

tnabil avatar Nov 24 '22 07:11 tnabil

Hey @anfibiacreativa , thanks for reporting this. Although the issue is known as you mentioned there is no indication of the error in the logs which is a painful experience for the user. To fix this, there are two active tasks we're working on

  1. There is an active PR which addresses the last problem you mentioned by automatically detecting the function language.
  2. We're working on adding more logs in the StaticSiteClient thereby providing user more context over the problem.

Hey @anfibiacreativa , we did a new STaticSiteClient release recently and you should be able to see the logs when deployment failure happens, please check this now.

sgollapudi77 avatar Dec 22 '22 06:12 sgollapudi77

Confirmed. Thank you.

anfibiacreativa avatar Feb 20 '23 14:02 anfibiacreativa

The PR for this issue is merged #562, will be out with the next release.

rupareddy5-21 avatar Mar 29 '23 06:03 rupareddy5-21