ITADN

Panic in exception_public.rs: Column number overflow (TryFromIntError) when executing code with long lines

#341Openmoredatarequired 创建于 2026-04-17
## Bug When Monty processes a file where any line is ≥ 65536 characters long, it panics with: ``` thread '<unnamed>' panicked at crates/monty/src/exception_public.rs:346:43: Column number overflow: TryFromIntError(()) ``` This surfaces in Python as a `pyo3_runtime.PanicException` and kills the process instead of returning a normal exception. ## Minimal reproduction ```python from pydantic_monty import Monty # Any line >= 65536 chars triggers the panic. # The line itself can be valid Python — the panic occurs when Monty # records a file position (e.g. for a NameError on the *next* line). code = "x = " + "a" * 65532 + "\ny = undefined_name" # line 1 is exactly 65536 chars Monty(code) # raises pyo3_runtime.PanicException: Column number overflow: TryFromIntError(()) ``` Verified boundary: - Line length 65535 → `MontyNameError` (correct, graceful) - Line length 65536 → **panic** ## Root cause Column offsets appear to be stored as `u16` (max 65535). A line of ≥ 65536 characters causes `TryFromIntError` when converting the byte offset to `u16` at `exception_public.rs:346`. ## Context - **pydantic-monty version**: 0.0.12 - **pydantic-ai-harness version**: 0.1.1 - Triggered in production when an LLM generates a long single-line Python expression inside a CodeMode tool call ## Expected behavior Graceful `MontyNameError` (or similar) rather than a process-level panic. Options: clamp to `u16::MAX`, use `u32`, or saturate.
0 条评论