Decompiler: improve handling of garbage input #2527
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.
User description
Summary
Improve handling of garbage logic lines that have been added via CLI.
Specifically, when an operator has too many operarands set, such as "set control profile, 1, 6, 1700"
Problem
The decompiler was eagerly decompiling both operandA and operandB for all action operations, even when operandB was unused. This caused incorrect type-specific validation warnings.
Example: SET_PROFILE (operation 42) only uses operandA for the profile number, but operandB contained garbage data (type=6/PID, value=1700), triggering:
Solution
Added operation-specific operand handling:
Additionally added version detection warnings for unexpected operands to detect firmware/configurator version mismatches when firmware adds new operand usage.
Changes
js/transpiler/transpiler/action_decompiler.js:operandAOnlyOperationsarray listing operations that only use operandAnoOperandOperationsarray listing operations that use no operandsExample new warning:
Benefits
Testing
PR Type
Bug fix
Description
Prevents incorrect validation warnings for unused operands in action operations
Adds operation-specific handling for operandA-only and no-operand operations
Implements version detection warnings for unexpected operand values
Skips decompilation of unused operands to avoid type-specific validation errors
Diagram Walkthrough
flowchart LR A["Action Operation"] --> B{"Operation Type?"} B -->|"No Operands"| C["Skip Both Operands"] B -->|"OperandA Only"| D["Skip OperandB"] B -->|"Both Operands"| E["Decompile Both"] C --> F["Check for Unexpected Values"] D --> F E --> G["Decompile Normally"] F --> H["Add Version Detection Warning"]File Walkthrough
action_decompiler.js
Add operation-specific operand handling and validationjs/transpiler/transpiler/action_decompiler.js
operandAOnlyOperationsarray listing 9 operations that only useoperandA
noOperandOperationsarray listing 7 operations that use nooperands
operands