From 88282637959947fe1c949ed1cba5987c9696f86d Mon Sep 17 00:00:00 2001 From: Ethan Chiu Date: Wed, 8 Jul 2020 14:00:12 -0400 Subject: [PATCH] Address situation if FileTable is null + add sanity check for adding file to fileTable --- src/Runner.Worker/ActionManifestManager.cs | 10 +++++++--- src/Runner.Worker/ExecutionContext.cs | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Runner.Worker/ActionManifestManager.cs b/src/Runner.Worker/ActionManifestManager.cs index a9eac9d9d..138755047 100644 --- a/src/Runner.Worker/ActionManifestManager.cs +++ b/src/Runner.Worker/ActionManifestManager.cs @@ -74,8 +74,12 @@ namespace GitHub.Runner.Worker var fileId = templateContext.GetFileId(fileRelativePath); // Add this file to the FileTable in executionContext if it hasn't been added already - // we use > since fileID is zero indexed - if (fileId > executionContext.FileTable?.Count) + // we use > since fileID is 1 indexed + if (executionContext.FileTable == null) + { + executionContext.FileTable = new string[0]; + } + else if (fileId > executionContext.FileTable.Count) { executionContext.FileTable.Add(fileRelativePath); } @@ -136,7 +140,7 @@ namespace GitHub.Runner.Worker if (actionDefinition.Execution == null) { executionContext.Debug($"Loaded action.yml file: {StringUtil.ConvertToJson(actionDefinition)}"); - throw new ArgumentException($"Top level 'runs:' section is required for {manifestFile}"); + throw new ArgumentException($"Top level 'runs:' section is required for {fileRelativePath}"); } else { diff --git a/src/Runner.Worker/ExecutionContext.cs b/src/Runner.Worker/ExecutionContext.cs index 83e47c74c..4655151a4 100644 --- a/src/Runner.Worker/ExecutionContext.cs +++ b/src/Runner.Worker/ExecutionContext.cs @@ -53,7 +53,7 @@ namespace GitHub.Runner.Worker Dictionary JobOutputs { get; } IDictionary EnvironmentVariables { get; } IDictionary Scopes { get; } - IList FileTable { get; } + IList FileTable { get; set; } StepsContext StepsContext { get; } DictionaryContextData ExpressionValues { get; } IList ExpressionFunctions { get; } @@ -150,7 +150,7 @@ namespace GitHub.Runner.Worker public Dictionary JobOutputs { get; private set; } public IDictionary EnvironmentVariables { get; private set; } public IDictionary Scopes { get; private set; } - public IList FileTable { get; private set; } + public IList FileTable { get; set; } public StepsContext StepsContext { get; private set; } public DictionaryContextData ExpressionValues { get; } = new DictionaryContextData(); public IList ExpressionFunctions { get; } = new List();