Skip to content
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

capture and report job deserialization errors #11179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Dec 24, 2024

The job.json file is passed to all update steps which means we need to be able to report all parsing errors as they occur.

Originally this work started because a requirement was specified in the job file that could not be parsed, so part of this PR is to return the well-known error illformed_requirement, represented as BadRequirementError.

Most of this PR was to make testing possible, but ultimately it comes down to 2 major changes:

  1. For the current hybrid Ruby/C# updater, only validate and report job file parsing errors in the discover command. All subsequent commands also parse the job file, but any failure to parse is fatal so we only need to actually report it there; all other instances can assume it's acceptable.
  2. For the new end-to-end updater, the clone command is the first time the job file is parsed, so the error handling was expanded there to specifically report the parse error and fail the entire update process.

While performing some manual tests, I discovered that the shape of the error objects returned by the end-to-end parser wasn't always correct, so I checked in the dependabot/cli repo to ensure the errors had the correct shape and added serialization tests for all error types to ensure this doesn't regress.

@brettfo brettfo requested review from a team as code owners December 24, 2024 00:32
@github-actions github-actions bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label Dec 24, 2024
{
"error-type": "illformed_requirement",
"error-detail": { message: error.message }
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code already existed in updater_error_details but this error occurs during the fetch phase of a NuGet update so it was simply copied here, too. This is a well-known error with a known shape.

@brettfo brettfo force-pushed the dev/brettfo/nuget-requirement-parse-error branch from 13f3ed2 to 9161873 Compare December 26, 2024 18:14
ErrorDetails = errorResult.ErrorDetails,
};
await DiscoveryWorker.WriteResultsAsync(repoRoot.FullName, outputPath.FullName, discoveryErrorResult);
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want this to always report error code 0 so that we get a chance to properly elevate the error type and details in native_helpers.rb below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: dotnet:nuget NuGet packages via nuget or dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant