Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 442 forks source link

Corrupted secret file D:\home\data\functions\secrets\host.json doesn't lead to meaningful error message #3053

Open davidebbo opened 6 years ago

davidebbo commented 6 years ago

I reproed this in v1 and v2, but let's focus on v2. In a clean new app, I removed the ending brace to make the json invalid.

In portail, when running the http function, all I saw is this cryptic response:

{
  "id": "2d2d9164-4ec9-4a82-8ed7-a38a07048186",
  "requestId": "9f77d6a5-a927-4b7f-aad4-8fe26218718d",
  "statusCode": 500,
  "errorCode": 0,
  "message": "An error has occurred. For more information, please check the logs for error ID 2d2d9164-4ec9-4a82-8ed7-a38a07048186"
}

In system logs, here was the full exception:

Newtonsoft.Json.JsonReaderException : Unexpected end of content while loading JObject. Path 'source', line 25, position 0.
   at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader,JsonLoadSettings options)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader,JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json,JsonLoadSettings settings)
   at Microsoft.Azure.WebJobs.Script.WebHost.ScriptSecretSerializer.ResolveSerializerAndRun[TResult](String secretsJson,Type secretsType,Func`3 func) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Security\Serialization\ScriptSecretSerializer.cs : 35
   at Microsoft.Azure.WebJobs.Script.WebHost.ScriptSecretSerializer.DeserializeSecrets[T](String secretsJson) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Security\Serialization\ScriptSecretSerializer.cs : 31
   at async Microsoft.Azure.WebJobs.Script.WebHost.SecretManager.LoadSecretsAsync(??) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Security\SecretManager.cs : 371
   at async Microsoft.Azure.WebJobs.Script.WebHost.SecretManager.LoadSecretsAsync[T](??) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Security\SecretManager.cs : 360
   at async Microsoft.Azure.WebJobs.Script.WebHost.SecretManager.GetHostSecretsAsync() at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Security\SecretManager.cs : 72
   at async Microsoft.Azure.WebJobs.Script.WebHost.Filters.AuthorizationLevelAttribute.GetAuthorizationResultAsync(??) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Filters\AuthorizationLevelAttribute.cs : 107
   at async Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.DetermineAuthorizationLevelAsync(HttpRequestMessage request) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\FunctionRequestInvoker.cs : 131
   at async Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.PreprocessRequestAsync(HttpRequestMessage request) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\FunctionRequestInvoker.cs : 108
   at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Controllers\FunctionsController.cs : 39
   at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
   at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Handlers\WebScriptHostHandler.cs : 42
   at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Handlers\SystemTraceHandler.cs : 54
   at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)

Let's try to make this a 'self-solve' scenario so it doesn't become a support call.

mathewc commented 6 years ago

Investigate what improvements we can make here.

fabiocav commented 5 years ago

@anirudhgarg should this be kept open? Will move this to Triaged in the meantime, but feel free to move to a different milestone as appropriate.