Invalid environment name defaults to production instead of failing gracefully
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to setup deployment of my web app to a preview environment where `DEPLOYMENT_ENVIRONMENT` is generated dynamically.
I am following the documentation in https://learn.microsoft.com/en-us/azure/static-web-apps/gitlab?tabs=vanilla-javascript
which instructs to use the following image: `registry.gitlab.com/static-web-apps/azure-static-web-apps-deploy`.
The image reads `DEPLOYMENT_ENVIRONMENT` variable to determine target environment.
If the environment name does not meet strict naming requirements (max 16 characters, limited ascii charset), the deployment defaults to Production.
**To Reproduce**
Steps to reproduce the behavior:
1. run `registry.gitlab.com/static-web-apps/azure-static-web-apps-deploy` image with invalid environment name (`DEPLOYMENT_ENVIRONMENT`) longer than 16 characters
2. An error message is printed out
> The environment name provided exceeds the character limit of 16.
3. Happy success message follows:
> Deployment Complete :)
> Visit your site at: https://your-production-app.azurestaticapps.net/
This results in the app being deployed to production instead of preview environment.
**Expected behavior**
Deployment should fail since environment name is not valid.
**Screenshots**
```
Status: Downloaded newer image for registry.gitlab.com/static-web-apps/azure-static-web-apps-deploy:latest
DeploymentId: 7116bebe-f158-450b-855d-49fca9617f9f
App Directory Location: '/root/app' was found.
Looking for event info
The environment name provided exceeds the character limit of 16.
Failed to get event info. Proceeding despite error.
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
---Oryx build logs---
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version: 0.2.20220621.1, Commit: 82ed84f0f3fd3a25ded3029f137601f54e7a1d05, ReleaseTagName: 20220621.1
Build Operation ID: |dem5rVLTdSs=.964f5d25_
Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.
---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
Finished building app with Oryx
No Api directory specified. Azure Functions will not be created.
Either no Api directory was specified, or the specified directory was not found. Azure Functions will not be created.
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0806795(s)
Status: InProgress. Time: 15.1383827(s)
Status: Succeeded. Time: 30.2043321(s)
Deployment Complete :)
Visit your site at: (REDACTED)
Thanks for using Azure Static Web Apps!
Exiting
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.