-
Notifications
You must be signed in to change notification settings - Fork 59
Add defensive checks for msix_info dictionary access #474
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
base: main
Are you sure you want to change the base?
Conversation
…idator, and vivado_utils Co-authored-by: ramseymcgrath <2006510+ramseymcgrath@users.noreply.github.com>
Co-authored-by: ramseymcgrath <2006510+ramseymcgrath@users.noreply.github.com>
Co-authored-by: ramseymcgrath <2006510+ramseymcgrath@users.noreply.github.com>
|
@copilot rebase |
I'm unable to perform a git rebase as my tooling doesn't support force-pushing, which is required for rebasing. The branch is currently up-to-date with origin/copilot/fix-keyerror-msix-info. If there have been updates to the base branch that need to be incorporated, you may need to:
|
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.
Pull Request Overview
This PR adds defensive programming to prevent potential KeyError exceptions when accessing MSI-X capability information, along with import path corrections and comprehensive test coverage.
Key Changes
- Added multi-layered defensive checks before accessing
msix_info["table_size"]in the preload_data method to handle None values, non-dict types, missing keys, and zero table sizes - Corrected import statements from
from string_utils importtofrom src.string_utils importacross 4 files to fix import errors - Added 3 unit tests covering edge cases: None msix_info, missing table_size key, and zero table_size
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/device_clone/msix.py | Added comprehensive defensive checks (None, type, key existence, value validation) before accessing msix_info dictionary |
| src/cli/vfio_handler.py | Corrected import path to use from src.string_utils import |
| src/file_management/option_rom_manager.py | Corrected import path to use from src.string_utils import |
| src/utils/post_build_validator.py | Corrected import path to use from src.string_utils import |
| src/vivado_handling/vivado_utils.py | Corrected import path to use from src.string_utils import |
| tests/test_msix_manager.py | Added 3 unit tests validating defensive behavior for None, missing keys, and zero table_size scenarios |
Comments suppressed due to low confidence (1)
src/file_management/option_rom_manager.py:22
- Import of 'log_debug_safe' is not used.
from src.string_utils import (
log_debug_safe,
log_error_safe,
log_info_safe,
log_warning_safe,
safe_format,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses potential KeyError when accessing
msix_info["table_size"]if the dictionary is None, malformed, or missing the key.Changes
src/device_clone/msix.py: Added comprehensive validation before dictionary access:
Import fixes: Corrected
from string_utils importtofrom src.string_utils importin 4 files (vfio_handler.py, option_rom_manager.py, post_build_validator.py, vivado_utils.py) that were blocking test executionTest coverage: Added 3 unit tests validating behavior when msix_info is None, missing keys, or has zero table_size
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.