Reputation: 21
We are currently experiencing a NewtonSoft.Json build issue in GitHub Actions for a new Nuxt3 static web app. The application builds and runs perfectly locally (npm run dev) but fails the build/deploy process when trying to deploy to Azure via GitHub actions. The exception being thrown during the build and the GitHub actions workflow yaml file are shown below:
`**`Build Operation ID: 75d5ecf1017c042b
OS Type : bullseye
Image Type : jamstack
Detecting platforms...
Error: Oops... An unexpected error has occurred.
Error: Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at Microsoft.Oryx.Detector.ParserHelper.ParseJsonFile(ISourceRepo sourceRepo, String filePath) in /usr/oryx/src/Detector/ParserHelper.cs:line 86
at Microsoft.Oryx.Detector.Hugo.HugoDetector.IsHugoJsonFile(ISourceRepo sourceRepo, String\[\] subPaths) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 218
at Microsoft.Oryx.Detector.Hugo.HugoDetector.IsHugoApp(ISourceRepo sourceRepo, String& appDirectory) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 145
at Microsoft.Oryx.Detector.Hugo.HugoDetector.Detect(DetectorContext context) in /usr/oryx/src/Detector/Hugo/HugoDetector.cs:line 49
at Microsoft.Oryx.BuildScriptGenerator.Hugo.HugoPlatform.Detect(RepositoryContext context) in /usr/oryx/src/BuildScriptGenerator/Hugo/HugoPlatform.cs:line 61
at Microsoft.Oryx.BuildScriptGenerator.DefaultPlatformsInformationProvider.GetPlatformsInfo(RepositoryContext context) in /usr/oryx/src/BuildScriptGenerator/DefaultPlatformsInformationProvider.cs:line 53
at Microsoft.Oryx.BuildScriptGenerator.DefaultBuildScriptGenerator.GenerateBashScript(BuildScriptGeneratorContext context, String& script, List\`1 checkerMessageSink) in /usr/oryx/src/BuildScriptGenerator/DefaultBuildScriptGenerator.cs:line 75
at Microsoft.Oryx.BuildScriptGeneratorCli.BuildScriptGenerator.TryGenerateScript(String& generatedScript, Exception& exception) in /usr/oryx/src/BuildScriptGeneratorCli/BuildScriptGenerator.cs:line 63
at Microsoft.Oryx.BuildScriptGeneratorCli.BuildCommand.Execute(IServiceProvider serviceProvider, IConsole console) in /usr/oryx/src/BuildScriptGeneratorCli/Commands/BuildCommand.cs:line 278
at Microsoft.Oryx.BuildScriptGeneratorCli.CommandBase.OnExecute(IConsole console) in /usr/oryx/src/BuildScriptGeneratorCli/Commands/CommandBase.cs:line 87`**`
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_MUSHROOM_036506E0F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_MUSHROOM_036506E0F }}
action: "close"
As part of my troubleshooting I also scaffolded a barebones Nuxt3 Static Web App with nuxi and provisioned a new Azure Static Web App and the application deployed without issue. However, once I integrated the code from the problematic application, I once again started receiving the above exception. The problematic application was also deployed as-is to Vercel without issue so it appears that this is an Azure-specific deployment issue. At the end of the day I'm not quite sure why we are getting a Newtonsoft.Json.JsonReaderException on a Nuxt3/node app as this is something I would expect to see on a .net app at runtime.
Upvotes: 2
Views: 92
Reputation: 8195
I tried deploying a sample Nuxt app via github actions and the deployment was successful, Refer below:-
The Nuxt app ran successfully locally like below:-
Create a Static web app and deploy the Nuxt app from the github repository like below:-
The Nuxt app got deployed successfully in Azure Static Web app like below:-
My github workflow script:-
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_GROUND_085802C10 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server" # Api source code path - optional
output_location: ".output/public" # Built app content directory - optional
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_GROUND_085802C10 }}
action: "close"
My github repository:-
My package.json:-
{
"name": "nuxt-3-starter",
"version": "1.0.0",
"description": "My Nuxt 3 Test",
"author": "Nuzhat Minhaz",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "3.0.0-rc.6"
}
}
Looks like you are facing an issue on the Azure platform level, Click on Diagnose and solve problems and click on Content Deployment to get insight on the Static web app deployment:-
You can also enable Application Insights and check the logs in Application insights like below to analyze your error:-
Upvotes: 0