properly report failure to deserialize job file #11780
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the C# NuGet updater fails to deserialize the
job.json
file, the error handler goes into a method that attempts to turn the exception into a dependabot-specific type. One of the exception types listed, however, is from an MSBuild binary which means that MSBuild needs to have been resolved first.This PR builds on the findings of @rhyskoedijk and forces MSBuild to have been loaded before the first time the job file is parsed. This behavior is really complicated to unit-test because by definition, all unit test runs have already loaded MSBuild. Subsequent calls to the updater don't need MSBuild pre-loaded in this way because if we get that far we already know the file is formatted correctly.
This also contains a fix to the end-to-end updater (code not live) to not attempt any filesystem operations if the
clone
command failed, which can also happen if the job file failed to parse correctly. The error reporting in theclone
handler doesn't rely on MSBuild pre-loads.