Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Jan 21, 2026

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:

Invalid PID operand value 1700. Valid range is 0-3.

Solution

Added operation-specific operand handling:

  • operandAOnlyOperations: Skip operandB decompilation for operations that only use operandA
  • noOperandOperations: Skip both operands for operations that use neither

Additionally added version detection warnings for unexpected operands to detect firmware/configurator version mismatches when firmware adds new operand usage.

Changes

  • Modified js/transpiler/transpiler/action_decompiler.js:
    • Added operandAOnlyOperations array listing operations that only use operandA
    • Added noOperandOperations array listing operations that use no operands
    • Skip decompilation of unused operands to prevent type-specific validation errors
    • Added warnings for unexpected non-zero operands (version detection)

Example new warning:

Unexpected operand B to Set Profile operation (type=6, value=1700). 
This may indicate a firmware version mismatch.

Benefits

  • Prevents type-specific validation errors on garbage data in unused operands
  • Preserves validation for operations that legitimately use PID/other operands
  • Provides version detection when firmware adds new operand usage
  • Shows operation name, type, and value for debugging

Testing

  • Tested with SET_PROFILE operation containing unused PID operand
  • Verified no type-specific error, only version detection warning
  • Confirmed decompilation still works for operations using both operands

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"]
Loading

File Walkthrough

Relevant files
Bug fix
action_decompiler.js
Add operation-specific operand handling and validation     

js/transpiler/transpiler/action_decompiler.js

  • Added operandAOnlyOperations array listing 9 operations that only use
    operandA
  • Added noOperandOperations array listing 7 operations that use no
    operands
  • Implemented conditional operand decompilation based on operation type
  • Added version detection warnings for unexpected non-zero operands
  • Prevents type-specific validation errors on garbage data in unused
    operands
+49/-3   

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 for
operations like SET_PROFILE (operation 42) which only uses operandA.

Example: SET_PROFILE with operandB type=6 (PID), value=1700 (garbage data) would trigger:
"Invalid PID operand value 1700. Valid range is 0-3."

Solution:
Added operation-specific operand handling with two categories:
- operandAOnlyOperations: Operations that only use operandA (skip operandB decompilation)
- noOperandOperations: Operations that use no operands (skip both)

Additionally, added version detection warnings for unexpected operands:
- Warns when unused operands have non-zero type or value
- Helps detect firmware/configurator version mismatches
- Shows operation name, type, and value for debugging

Example warning: "Unexpected operand B to Set Profile operation (type=6, value=1700).
This may indicate a firmware version mismatch."

Benefits:
- Prevents type-specific validation errors on garbage data in unused operands
- Preserves validation for operations that legitimately use PID/other operands
- Provides version detection when firmware adds new operand usage
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@sensei-hacker sensei-hacker changed the title Fix JS Programming decompiler incorrect operand validation warnings Decompiler: improve handling of garbage input Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant