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

Failed to load staticwebapp.config.json schema on start

Open StanSymphonia opened this issue 3 years ago • 71 comments

I'm using the latest version 1.1.4

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

Describe the bug When starting an app with swa start I get WARNING: Failed to load staticwebapp.config.json schema. Continuing without validation!. Even if it's just a warning and is referring to the schema file (not the config itself) staticwebapp.config.json doesn't work as expected. e.g. none of the routes declared is working.

To Reproduce Steps to reproduce the behavior:

  1. Go to any swa app
  2. Type in command 'swa start'
  3. See warning in console
  4. Check in browser any routes declared -> won't work.

Expected behavior staticwebapp.config.json to work. Routes and any other settings declared to work.

Desktop (please complete the following information):

  • OS: Windows
  • Version: 11

Additional context After investigating this issue i have discovered that the URL used to load the config schema is hardcoded: https://github.com/Azure/static-web-apps-cli/blob/affefb24872286a542fe7bbd54340648ec3294d0/src/core/utils/user-config.ts#L168C13-L168C13 . At this moment, the website https://www.schemastore.org/ which is hosting the schema file, is down (error 503). Allowing loading the schema file only from a single website has created a single point of failure which we are experiencing right now.

staticwebapp.config.json has a property $schema, but as you can see the value is not used for actually loading the schema. My suggestion is to allow the user to provide a value for $schema (in order to no longer depend on https://www.schemastore.org/ ).

Thank you.

Edit: there's currently an issue on Schemastore repository: https://github.com/SchemaStore/schemastore/issues/3303

StanSymphonia avatar Oct 11 '23 10:10 StanSymphonia

I'm also seeing this warning, but routes are loading okay. I am using a customised config file swa-cli-config.json

My redirect from /login causes an error and the swa auth emulator does not seem to be protecting/allowing routes correctly. Trying to determine if related to above issue or not...

LiamOSullivan avatar Oct 11 '23 12:10 LiamOSullivan

I have this issue also. It fails silently and won't load my settings. I use the config to set CORS, so my deployment is not accessible at all from my app. I cannot deploy anymore until I have a solution for this. I'm completely blocked.

Please, do you have a solution ?

abaudhuin avatar Oct 11 '23 12:10 abaudhuin

I'm also running into this issue. Just had a new deployment, and users are redirected to 404 page if they try to access links directly or refresh the page.

froleo avatar Oct 11 '23 12:10 froleo

Seeing the same problem. This does also affect the swa deploy command leading to a not working SWA

avalor1 avatar Oct 11 '23 12:10 avalor1

Temporary solution (what I did):

  1. Go to %userprofile%\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\core\utils (for Windows).
  2. Open user-config.js.
  3. Search for https://json.schemastore.org/staticwebapp.config.json.
  4. Upload staticwebapp.config.json to blob storage (for example) or use my file: https://stcuberdonintegration.blob.core.windows.net/assets/staticwebapp.config.json (Will be removed in 24H)
  5. Replace https://json.schemastore.org/staticwebapp.config.json with your remote path.

aresofficial avatar Oct 11 '23 13:10 aresofficial

Temporary solution (what I did):

  1. Go to %userprofile%\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\core\utils (for Windows).
  2. Open user-config.js.
  3. Search for https://json.schemastore.org/staticwebapp.config.json.
  4. Upload staticwebapp.config.json to blob storage (for example) or use my file: https://stcuberdonintegration.blob.core.windows.net/assets/staticwebapp.config.json (Will be removed in 24H)
  5. Replace https://json.schemastore.org/staticwebapp.config.json with your remote path.

Confirm this fix by @aresofficial for the issue I observed...

I'm also seeing this warning, but routes are loading okay. I am using a customised config file swa-cli-config.json

My redirect from /login causes an error and the swa auth emulator does not seem to be protecting/allowing routes correctly. Trying to determine if related to above issue or not...

LiamOSullivan avatar Oct 11 '23 14:10 LiamOSullivan

I can confirm that issue as well on 1.1.4. Also, the fix posted by @aresofficial is working for me.

That's really strange, how Azure position Static Web Apps as production-ready service, where your app can be totally inaccessible because of downtime on 3rd party service. Moreover, not a single failure was seen, swa deploy will silently deploy your app and destroy all routes. That's "amazing"

loadaverage avatar Oct 11 '23 15:10 loadaverage

As we are on linux when deploying, sadly the workaround does not work. One approach could be to setup a webserver which serves the schema. One could then point the building/deploying machine for the SWA to this server via a hosts entry :thinking:

avalor1 avatar Oct 12 '23 06:10 avalor1

It seems to be fixed.

abaudhuin avatar Oct 12 '23 12:10 abaudhuin

Yes and no... someone threw more hardware on the problem so it works for now but the problem persists. One still depends on the availability of https://www.schemastore.org/. Not quite what i would call "fixed" :)

avalor1 avatar Oct 12 '23 12:10 avalor1

There was some problem in https://json.schemastore.org so that swa-cli got Error 500 Timeout. I have validate that it works well now, so I will close the issue. Feel free to repoen it if the error occurs again.

cjk7989 avatar Oct 16 '23 02:10 cjk7989

Really? Is it fixed so that when the schemastore isn't available it at least throws some kind of error and does not deploy a not working swa?.. I think it is not fixed.

avalor1 avatar Oct 16 '23 05:10 avalor1

I agree with @avalor1 . We should not depend on a third-party service which can become unavailable without notice.

Edit: My understanding is that the purpose of https://json.schemastore.org/ is to be used by various IDEs and VSCode extensions and SWA-CLI is using it for essential functionalities (build and deploy); even then it just logs a warning if it's unavailable. At the very least, on deployment it should throw an error when the service is unavailable. This way we'll avoid having broken SWAs in production. (and again wait for the service to become available 🙃)

StanSymphonia avatar Oct 16 '23 06:10 StanSymphonia

The issue is not fixed, Static Web Apps CLI is still unstable. It's only a matter of time before problem recurs (e.g. because of outage on schemastore)

Deployment should at least not silently destroy routes, otherwise Static Web Apps can't be production-ready (as now). @cjk7989 can you please escalate this issue?

loadaverage avatar Oct 17 '23 22:10 loadaverage

As others mentioned, this is still not fixed.

rf-0 avatar Oct 28 '23 16:10 rf-0

Hi all, we have published [email protected], which will throw an error if staticwebapp.config.json schema is failed to be download. And we plan to design a fallback method to completely fix the issue in the next version. Thanks very much for your feedback and suggestions.

cjk7989 avatar Nov 07 '23 06:11 cjk7989

I think validating the schema should be optional, either by not throwing an error or skipping it all together via a flag.

Also the current log message ("Continuing without validation") implies that the validation is optional right now, which is not the case since it breaks the build.

Either way, the domain https://json.schemastore.org/ is currently not listed in the troubleshooting section as domains that should be added to your firewall.

HendrikN avatar Nov 08 '23 09:11 HendrikN

The current error is still "Continuing without validation". That will confuse users since it's aborting execution.

HendrikN avatar Nov 15 '23 14:11 HendrikN

I see this issue in 1.1.6. Emulator does not work without internet. Fails to start.

[swa] ✖ Failed to load staticwebapp.config.json schema. Continuing without validation!
[swa] node ".pnpm/@[email protected]/node_modules/@azure/static-web-apps-cli/dist/msha/server.js" exited with code 0

offbeatful avatar Feb 11 '24 21:02 offbeatful

Good morning. Can't locally start my Azure static web app because .... network timeout at: https://json.schemastore.org/staticwebapp.config.json

image

The schema store is just sending 429 and 503s

image

image

I agree that this is a weird network dependency on what should should be "Airplane mode" type local dev work.

twitthoeft-gls avatar Mar 01 '24 16:03 twitthoeft-gls