Yicong-Huang opened a new issue, #4511:
URL: https://github.com/apache/texera/issues/4511

   ## Task Summary
   
   `WorkerDebugCommandHandler.translate_debug_command` 
(`amber/src/main/python/core/architecture/handlers/control/debug_command_handler.py`)
 has four known correctness gaps surfaced by the new tests added in #4510. All 
produce either an unhelpful exception or a malformed pdb command. The frontend 
doesn't trigger them today, but the RPC boundary should not trust that.
   
   ### 1. Empty / whitespace-only command crashes with a useless error
   
   ```python
   debug_command, *debug_args = command.strip().split()
   ```
   
   For `cmd = ""` or `cmd = "   "`, the unpack raises `ValueError: not enough 
values to unpack (expected at least 1, got 0)`. The handler doesn't catch it, 
so the RPC caller sees a stack trace.
   
   **Fix:** validate input at the top of the function and raise 
`ValueError(\"debug command cannot be empty\")` (or return early), so the 
failure mode is intentional and clearly named.
   
   ### 2. `b foo.py:5` gets re-prefixed → `b my_udf:foo.py:5`
   
   If the user already typed an explicit `filename:lineno`, the translator 
naively prepends the module again, producing a string pdb can't parse.
   
   **Fix:** if `debug_args[0]` already contains `:`, skip the module prefix.
   
   ### 3. `b my_func` (function name) becomes `b my_udf:my_func`
   
   Per pdb docs: `b ([filename:]lineno | function) [, condition]`. When 
prefixed with `filename:`, pdb expects a **lineno**, not a function name. The 
current code rewrites function-name args anyway, so `b my_func` arrives at pdb 
as `b my_udf:my_func`, which is invalid.
   
   **Fix:** only prepend the module when `debug_args[0]` is numeric (e.g. 
`debug_args[0].isdigit()` or wrapped `int()`). Otherwise pass the function name 
through unchanged.
   
   ### 4. `operator_module_name = None` renders as the literal string `\"None\"`
   
   If the executor hasn't been initialized yet, `b 5` translates to `b None:5`, 
which pdb tries to look up as a module named `None`.
   
   **Fix:** explicitly check `if module_name is None` and either raise a 
descriptive error (`\"executor not initialized; cannot set breakpoint yet\"`) 
or fall back to no prefix.
   
   ## Proposed Action
   
   Implement all four fixes in `translate_debug_command`. Update the tests 
added in #4510 — the four `pytest.raises(ValueError)` / quirk-pinning cases 
will need to be flipped to assert the new descriptive errors / new correct 
behavior.
   
   ## Priority
   
   P2 – Medium (correctness; not currently triggered but easy footgun for any 
new client of the debugger RPC)
   
   ## Task Type
   
   - [x] Code Implementation
   - [x] Testing / QA


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to