Repository navigation
Description
#5815 fixed crashes when a library import argument cannot be converted. Argument and variable conversion is used in many other places too, and most of them handle only ValueError. Argument conversion normally fails with ValueError, but built-in converters can also raise other exceptions. The whole execution then crashes with Unexpected error, exit code 255, and no log or report. #5815 already mentioned this for listeners.
Listener Listener.py:
from datetime import timedelta
class Listener:
ROBOT_LISTENER_API_VERSION = 3
def __init__(self, timeout: timedelta = timedelta()):
self.timeout = timeoutRunning robot --listener Listener.py:1e20 example.robot stops immediately:
[ ERROR ] Unexpected error: OverflowError: Python int too large to convert to C int
With --listener Listener.py:invalid the error is reported, and execution continues:
[ ERROR ] Taking listener 'Listener.py:invalid' into use failed: Importing listener '.../Listener.py' failed: Argument 'timeout' got value 'invalid' that cannot be converted to timedelta: Invalid time string 'invalid'.
Exceptions that I have seen escaping:
OverflowErrorfromtimedelta, for example with1e20orinf.TypeErrorfromsetandfrozensetwith unhashable items, for example[[1]].
Affected places, all verified on current master (4a757d7) with Python 3.13:
- Everything imported with
robot.utils.Importer, becauseImporter._instantiate_classhandles onlyValueError:--listener- library listeners given as strings with arguments
- custom
--consoleloggers --prerunmodifier--prerebotmodifier, with bothrobotandrebot. Withrobot,output.xmlis written, butlog.htmlandreport.htmlare not.--parser
- Typed command line variables, such as
--variable "X: timedelta:1e20".VariableScopes._convert_cli_variablehandles onlyValueError. - Typed variables in the Variables section, such as
${X: timedelta} 1e20, in suite and resource files.VariableResolver._converthandles onlyValueErrorandTypeError. - With keyword calls the execution does not crash, but the failure is the raw
OverflowError: Python int too large to convert to C intinstead of the normal conversion error message.
TypeInfo.convert is public API and documents that it raises ValueError if conversion fails. With these inputs it raises OverflowError or TypeError instead.
This is not a regression. utils.Importer has supported argument conversion since RF 4.0, and typed variables have existed since RF 7.3.
Proposed fix: make TypeConverter.convert turn other exceptions into ValueError. CustomConverter has done the same with custom converters since RF 5.0 (#4088). Then TypeInfo.convert follows its documented contract, and all callers that already handle ValueError work without changes. RecursionError should still be re-raised. Otherwise deeply nested values of recursive type aliases would fall through to the next union member, such as str, and keywords would get silently converted data. TimeoutExceeded, KeyboardInterrupt and SystemExit are not Exceptions, so they are not affected.
Messages and behavior change only for these previously crashing or odd failures:
- The normal conversion error format is used, for example
ValueError: Argument 'arg' got value '1e20' that cannot be converted to timedelta: OverflowError: Python int too large to convert to C intinstead ofOverflowError: Python int too large to convert to C int. - In unions the next member type is tried, as with
ValueError. For example,timedelta | floatwith1e20now gives the float1e20. - Conversion based on the default value type works as with
ValueError: the original value is used if conversion fails.
No existing ValueError message changes, and the existing unit and acceptance tests pass unchanged. This also does not replace the TODOs added in #5815 about ArgumentSpec.convert raising only DataErrors. It makes that change a bit easier, because only ValueErrors would need to be handled there.
Not covered, separate and much less likely: extremely deeply nested literals given to list, dict, and other converters that use ast.literal_eval can raise RecursionError or MemoryError ("Parser stack overflowed"). RF deliberately re-raises MemoryError, so these can still crash at the places listed above.
I'll submit a pull request with a fix.
AI/tooling disclosure: This issue was prepared with assistance from Claude Code. I reviewed the result manually, understand the reported problem, and verified it locally.
Activity
pekkaklarck commentedon Oct 22, 2026
Good catch. This is a severe issue, but I don't think this is as severe as #5815 was. I agree converting all conversion errors to ValueErrors makes sense.
[-]Execution crashes if argument conversion fails with other exception than `ValueError`[/-][+]Argument conversion failing unexpectedly causes bad error messages with keywords and crashes elsewhere (e.g. with listeners)[/+]Fix crash when argument conversion fails with other exception than `V…
Fix crash with too complex expressions in argument conversion
Fix crash when argument conversion fails with other exception than `V…
Better handling for RecursionError in type conversion