-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Error Messaging for Actions by Using ExecutionContext's FileTable as Single Source of Truth and by Passing FileID to All Children Tokens. #564
Conversation
…bles => but it doesn't 'stick'
…actions/runner into users/ethanchewy/compositeenv
…actions/runner into users/ethanchewy/compositeenv
…actions/runner into users/ethanchewy/compositeenv
|
|
// Clean up file name real quick | ||
// Instead of using Regex which can be computationally expensive, | ||
// we can just remove the # of characters from the fileName according to the length of the basePath | ||
string basePath = _hostContext.GetDirectory(WellKnownDirectory.Actions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HostContext.GetDirectory()
{ | ||
Trace.Error($"Action.yml load error: {error.Message}"); | ||
executionContext.Error(error.Message); | ||
} | ||
|
||
throw new ArgumentException($"Fail to load {manifestFile}"); | ||
throw new ArgumentException($"Fail to load {fileName}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this always shows actions.yml
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO for ethan: Change variable name top a more clear name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline, it's the relative path. Would it help to name the variable relative___
?
@@ -31,7 +31,6 @@ internal partial class TemplateEvaluator | |||
Boolean omitHeader = false) | |||
{ | |||
TemplateToken result; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo this. 😆
@@ -160,13 +160,20 @@ public class PipelineTemplateEvaluator | |||
} | |||
|
|||
public List<ActionStep> LoadCompositeSteps( | |||
TemplateToken token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to copy this change back to server.
var fileId = templateContext.GetFileId(fileName); | ||
|
||
// Add this file to the FileTable in executionContext | ||
executionContext.FileTable.Add(fileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you add the "fileName" the fileId
should match executionContext.FileTable.Length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only add if new
@@ -297,7 +311,8 @@ public ActionDefinitionData Load(IExecutionContext executionContext, string mani | |||
private ActionExecutionData ConvertRuns( | |||
IExecutionContext executionContext, | |||
TemplateContext context, | |||
TemplateToken inputsToken) | |||
TemplateToken inputsToken, | |||
Int32 fileID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this used?
@@ -291,7 +291,7 @@ public async Task RunAsync(ActionRunStage stage) | |||
// Error | |||
if (exitCode != 0) | |||
{ | |||
ExecutionContext.Error($"Process completed with exit code {exitCode}."); | |||
ExecutionContext.Error($"Process completed with exit code {exitCode}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@@ -160,13 +160,20 @@ public class PipelineTemplateEvaluator | |||
} | |||
|
|||
public List<ActionStep> LoadCompositeSteps( | |||
TemplateToken token) | |||
TemplateToken token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont forget to revert this
…/ethanchewy/compositeFileTable
…file to fileTable
|
||
// Add this file to the FileTable in executionContext if it hasn't been added already | ||
// we use > since fileID is 1 indexed | ||
if (fileId > executionContext.FileTable?.Count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need FileTable?
anymore, or should this just be FileTable
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we don't need it anymore since the FileTable should always be non null. Will update this to executionContext.FileTable.Count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch -ty
// Add the file table | ||
if (_fileTable?.Count > 0) | ||
// Add the file table from the Execution Context | ||
if (executionContext.FileTable?.Count > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question here, i think we can drop the ?
now
…d never be non null
…able as Single Source of Truth and by Passing FileID to All Children Tokens. (actions#564) * Composite Action Run Steps * Env Flow => Able to get env variables and overwrite current env variables => but it doesn't 'stick' * clean up * Clean up trace messages + add Trace debug in ActionManager * Add debugging message * Optimize runtime of code * Change String to string * Add comma to Composite * Change JobSteps to a List, Change Register Step function name * Add TODO, remove unn. content * Remove unnecessary code * Fix unit tests * Fix env format * Remove comment * Remove TODO message for context * Add verbose trace logs which are only viewable by devs * Initial Start for FileTable stuff * Progress towards passing FileTable or FileID or FileName * Sort usings in Composite Action Handler * Change 0 to location * Update context variables in composite action yaml * Add helpful error message for null steps * Pass fileID to all children token of root action token * Change confusing term context => templateContext, Eliminate _fileTable and only use ExecutionContext.FileTable + update this table when need be * Remove unnessary FileID attribute from CompositeActionExecutionData * Clean up file path for error message * Remove todo * Fix Workflow Step Env overiding Parent Env * Remove env in composite action scope * Clean up * Revert back * revert back * add back envToken * Remove unnecessary code * Add file length check * Clean up * Figure out how to handle set-env edge cases * formatting * fix unit tests * Fix windows unit test syntax error * Fix period * Sanity check for fileTable add + remove unn. code * revert back * Add back line break * Fix null errors * Address situation if FileTable is null + add sanity check for adding file to fileTable * add line * Revert * Fix unit tests to instantiate a FileTable * Fix logic for trimming manifestfile path * Add null check * Add filetable to testing file, remove ? since we know filetable should never be non null
Branched off from: #557
This PR enables file names to be included in action error messages.
Our goal is to ensure that the fileIDs are associated with all the children tokens in the action.yml so that error messages reference the correct action file to allow for easier debugging. Also, we want to make sure that the FileTable is updated correctly throughout the process to ensure that Error messages will reference always the correctly associated file.
In this PR, we also refactor the code in
ActionManifestManager
to allow for passingfileID
s to the children tokens. Originally, there was a_fileTable
attribute forActionManifestManager
instances as well as aFileTable
for ExecutionContext instances. To reduce confusion and potential bugs in the future when we have nested actions, we refactored how theFileTable
is used so that onlyExecutionContext.FileTable
is referenced. In theActionManifestManager
to ensure that only 1 fileTable (aka the ExecutionContext'sfileTable
) is referenced. Moreover, we add functionality to ensure that theFileTable
is updated every time we load an Action yaml.tl;dr ExecutionContext's FileTable is now the "source of truth" for any filetable related matters.
Demos:
=> Before error message: https://github.com/ethanchewy/testing-actions/actions/runs/144061679
(Line: 13, Col: 11): Unexpected value 'run:::::'
=> After PR error message: https://github.com/ethanchewy/testing-actions/actions/runs/145235133
ethanchewy/testing-composite-errors/v3/action.yml (Line: 13, Col: 11): Unexpected value 'run:::::'
More demos:
action.yml
Error Messaging after delayed evaluation:
https://github.com/ethanchewy/testing-actions/actions/runs/145233958
ethanchewy/testing-composite-errors/v4/action.yml (Line: 13, Col: 16): Unexpected symbol: '"not'. Located at position 10 within expression: fromJson("not json"))