Resolve the error 'Could not install firmware.' - Fixes #3195#3496
Open
gaojulong wants to merge 1 commit intobluerobotics:masterfrom
Open
Resolve the error 'Could not install firmware.' - Fixes #3195#3496gaojulong wants to merge 1 commit intobluerobotics:masterfrom
gaojulong wants to merge 1 commit intobluerobotics:masterfrom
Conversation
…3195 For burning custom firmware, the validation of 'GenericSerial' should be skipped. Resolve the error 'Could not install firmware.'
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR refactors _validate_apj to skip board_id checks for GenericSerial devices, replaces broad exception handling with specific catches and improved error messages, and reorganizes the validation flow for better readability. Class diagram for updated _validate_apj logic in FirmwareInstallclassDiagram
class FirmwareInstall {
+_validate_apj(firmware_path: pathlib.Path, platform: Platform)
}
class Platform {
<<enumeration>>
GenericSerial
// ... other platform types
}
FirmwareInstall --> Platform: uses
Flow diagram for firmware validation with GenericSerial skipflowchart TD
A[Start firmware validation] --> B{Platform == GenericSerial?}
B -- Yes --> C[Skip board_id validation]
C --> D[Return]
B -- No --> E[Get expected_board_id]
E --> F{expected_board_id == -1?}
F -- Yes --> G[Raise UnsupportedPlatform]
F -- No --> H{firm_board_id == -1?}
H -- Yes --> I[Raise InvalidFirmwareFile: missing board_id]
H -- No --> J{firm_board_id != expected_board_id?}
J -- Yes --> K[Raise InvalidFirmwareFile: board_id mismatch]
J -- No --> L[Return]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The unindented
returnafter the GenericSerial skip will short-circuit validation for all platforms—move it inside theif platform == Platform.GenericSerialblock so only GenericSerial avoids the board_id checks. - Consider restructuring the JSON load and board_id logic into a clear sequence (load → generic-skip → validate) to reduce nested blocks and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The unindented `return` after the GenericSerial skip will short-circuit validation for all platforms—move it inside the `if platform == Platform.GenericSerial` block so only GenericSerial avoids the board_id checks.
- Consider restructuring the JSON load and board_id logic into a clear sequence (load → generic-skip → validate) to reduce nested blocks and improve readability.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
For burning custom firmware, the validation of 'GenericSerial' should be skipped. Resolve the error 'Could not install firmware.'
Summary by Sourcery
Skip board_id validation for GenericSerial platform and improve firmware file load error handling to resolve 'Could not install firmware' error.
Bug Fixes:
Enhancements: