Skip to content

Commit 8726bf3

Browse files
committed
handle nullref for empty host.json. Closes #101
1 parent 622fd88 commit 8726bf3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ private void CheckHostJsonId()
150150
{
151151
if (FileSystemHelpers.FileExists(ScriptConstants.HostMetadataFileName))
152152
{
153-
var hostConfig = JsonConvert.DeserializeObject<JObject>(FileSystemHelpers.ReadAllTextFromFile(ScriptConstants.HostMetadataFileName));
153+
var hostJsonContent = FileSystemHelpers.ReadAllTextFromFile(ScriptConstants.HostMetadataFileName);
154+
var hostConfig = string.IsNullOrEmpty(hostJsonContent)
155+
? new JObject()
156+
: JsonConvert.DeserializeObject<JObject>(FileSystemHelpers.ReadAllTextFromFile(ScriptConstants.HostMetadataFileName));
154157
if (hostConfig["id"] == null)
155158
{
156159
ColoredConsole.Out

0 commit comments

Comments
 (0)