Summary
When exclude contains an invalid regex pattern, convert_to_title_case raises a raw re.error instead of a proper ValueError or DataError.
Version
Robot Framework 7.4.2,
Python 3.12
Reproduce
Python:
from robot.libraries.String import String
s = String()
s.convert_to_title_case("hello", exclude="[")
# re.error: unterminated character set at position 0
Robot:
*** Settings ***
Library String
*** Test Cases ***
Convert To Title Case with invalid regex in exclude
[Documentation] Bug: re.error raised instead of ValueError/DataError for invalid regex in exclude
Convert To Title Case hello [
Expected
A ValueError or DataError with a clear message, e.g.:
Invalid exclude pattern '[': unterminated character set
Actual
re.error: unterminated character set at position 0
Location
src/robot/libraries/String.py line 157 — the re.compile(exclude) call is not wrapped in a try/except.
Summary
When
excludecontains an invalid regex pattern,convert_to_title_caseraises a rawre.errorinstead of a properValueErrororDataError.Version
Robot Framework 7.4.2,
Python 3.12
Reproduce
Python:
Robot:
Expected
A
ValueErrororDataErrorwith a clear message, e.g.:Invalid exclude pattern '[': unterminated character setActual
Location
src/robot/libraries/String.pyline 157 — there.compile(exclude)call is not wrapped in a try/except.