Replace crash with graceful error handling in ListRequirement.unsatis…#1999
Open
IB-Mustafa wants to merge 1 commit into
Open
Replace crash with graceful error handling in ListRequirement.unsatis…#1999IB-Mustafa wants to merge 1 commit into
IB-Mustafa wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this fixes
There's an old TODO in
ListRequirement.unsatisfied()(
volatility3/framework/configuration/requirements.py) about whether raising a TypeError is the right way to handle an invalid config value.The problem
Most checks in this method fail gracefully — they log a message and return, letting the program continue safely. But one check (when the value isn't a list at all) instead raises a
TypeError, which crashes the whole program. It seemed inconsistent with every other check right next to it.The fix
Replaced the
raise TypeError(...)with the same graceful pattern used elsewhere in the method — log it, then return{config_path: self}to mark the requirement as unsatisfied, instead of crashing.How I tested it
I tested it manually with a small script: passed in a string where a list was expected, and confirmed that before the fix it raised a TypeError, and after the fix it returned a normal "unsatisfied" result without crashing — same as the other checks in the function.
Happy to add a formal test if that's preferred.