Conversation
387cd26 to
7ef67c6
Compare
There was a problem hiding this comment.
🔎 What do you think of calling ErrorHandler here 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.
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 DependabotError class to error-details hash to be a convention where every error implemented the "presentation" hash directly but that's a big lift and pretty outside the critical path.
updater/lib/dependabot/updater.rb
Outdated
There was a problem hiding this comment.
Thanks for this context 😄
updater/lib/dependabot/updater.rb
Outdated
f32dcb4 to
492620a
Compare
This should have been removed in #6810 Our API returns a 4xx response and a blank job description if a job that has already been processed is requested, but this no longer happens within the Dependabot::Updater code. The layer that constructs the docker containers which the code runs in will not be able to inject a file and will bail out before ever invoking any Ruby
492620a to
d4ebbcc
Compare
Background
In the Updater, if file parsing fails, we get an empty value for "dependencies" at the code here.
We lazily evaluate
dependenciesin theDependabot::Updater#runmethod which results in us quietly exiting the job in two difference places based on this if statement:For a new update,
[]means we don't iterate and the job silently ends on the line:For updating an existing PR, we end up here:
This will nearly always result in
[] != [$at_least_one_dep], so we exit. We don't close the PR as the parser failure has placed an error on the job, but we could have the same outcome by stopping if the parse fails.The Change
This branch yoinks all file parsing concerns to the very start of the
UpdateFileCommandso we retrieve the files from the job definition, decode them and parse them before starting into any actual update logic.This means that all exception handling around parsing failures can happen immediately and clearly around the instantiation of the
Dependabot::DependencySnapshot, removing a significant concern from theDependabot::Updaterclass and clarifying that we only expect update time errors to be handled inside it, not parse errors.Rationale
The main reason to do this now is we still need to split out another 3 "Operation" classes in the style of #6866.
This work will break the Updater down further, allowing us to pull apart its responsibilities and break the test cases across some concrete classes. In its current state, file parsing would end up becoming a concern of every responsibility, but a code walk tells us that we can short-circuit this and turn it into a precondition.
This will significantly reduce the remaining work by allowing the rest of the class breakdown to be focused on just generating updates and posting PRs.