-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Updater] Perform Dependency file parsing early, and fail fast if there's a problem #6906
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8cd7ff8
Enforce non-nil expectations for base commit and files
brrygrdn bc9a74f
Dependabot::Snapshot hydrates dependency files at instantiation
brrygrdn 8f3342a
Handle parser errors in the UpdateFilesCommand
brrygrdn d675286
Migrate experiment test for the file parser into the snapshot spec
brrygrdn c28fb5b
Remove a test case that can no longer happen for updating PRs
brrygrdn f9522c0
Remove parse-specific tests from the Updater, Remove duplicates
brrygrdn d841375
Remove a test for a nil job
brrygrdn f16f959
Get rid of some rubocop exceptions :tada:
brrygrdn d4ebbcc
Assign dependencies during init
brrygrdn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,16 +133,10 @@ def check_and_update_existing_pr_with_error_handling(dependencies) | |
| # DependencyChange as we build it up step-by-step. | ||
| def check_and_update_pull_request(dependencies) | ||
| if dependencies.count != job.dependencies.count | ||
| # TODO: Remove the unless statement | ||
| # | ||
| # This check is to determine if there was an error parsing the dependency | ||
| # dependency file. | ||
| # | ||
| # For update existing PR operations we should early exit after a failed | ||
| # parse instead, but we currently share the `#dependencies` method | ||
| # with other code paths. This will be fixed as we break out Operation | ||
| # classes. | ||
| close_pull_request(reason: :dependency_removed) unless service.errors.any? | ||
| # If the job dependencies mismatch the parsed dependencies, then | ||
| # we should close the PR as at least one thing we changed has been | ||
| # removed from the project. | ||
|
||
| close_pull_request(reason: :dependency_removed) | ||
| return | ||
| end | ||
|
|
||
|
|
@@ -591,8 +585,6 @@ def existing_pull_request(updated_dependencies) | |
| created_pull_requests.find { |pr| Set.new(pr) == new_pr_set } | ||
| end | ||
|
|
||
| # rubocop:disable Metrics/AbcSize | ||
| # rubocop:disable Metrics/PerceivedComplexity | ||
|
||
| def dependencies | ||
| all_deps = dependency_snapshot.dependencies | ||
|
|
||
|
|
@@ -632,12 +624,7 @@ def dependencies | |
| allowed_deps.reject { |d| job.vulnerable?(d) } | ||
|
|
||
| deps | ||
| rescue StandardError => e | ||
| error_handler.handle_parser_error(e) | ||
| [] | ||
| end | ||
| # rubocop:enable Metrics/PerceivedComplexity | ||
| # rubocop:enable Metrics/AbcSize | ||
|
|
||
| def update_checker_for(dependency, raise_on_ignored:) | ||
| Dependabot::UpdateCheckers.for_package_manager(job.package_manager).new( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
🔎 What do you think of calling
ErrorHandlerhere and leaving the logic in that class? I really like the idea of isolating error handling, but I also see the benefit of leaving the logic close to where error handling needs to happen.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.
I'm split on this as I originally created that class to contain these two long methods, but because it is namespaced within the Updater it felt right to remove the concern from it as being out of bounds.
I'm still a bit uncertain of the long term place for that helper, ideally we'd push the need to do the dance to get from
DependabotErrorclass toerror-detailshash to be a convention where every error implemented the "presentation" hash directly but that's a big lift and pretty outside the critical path.