Skip to content

Harden Udon debug command translation against bad input #4511

Closed

Description

@Yicong-Huang

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

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

  • Code Implementation
  • Testing / QA

Activity

  1. changed the title [-]fix(amber-python): harden Udon debug command translation against bad input[/-] [+]Harden Udon debug command translation against bad input[/+] on Apr 26, 2026
  2. self-assigned this
    on Apr 26, 2026
  3. added a commit that references this issue on Apr 27, 2026
    d33603a
  4. added a commit that references this issue on Jun 22, 2026
    d8e5a7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions