Open HolQue opened 3 weeks ago
Addendum:
(1)
In general: In the context of the JsonPreprocessor a user has no possibility to define regular expressions at any position. In JSON files a user can only define names and values. And he can do this with the help of ${}
expressions, but nothing else.
Therefore I expect, that a user never will see regular expression error messages like listed above.
Errors w.r.t. regular expressions will therefore be in every case errors made by the developer of the application, but not made by a user.
(2)
In JsonPreprocessor code I see some re.compile()
calls, but not encapsulated in a try/except block. This causes very anonymous error messages like
unbalanced parenthesis at position ...
Also a developer may need time now to find the position in the code that causes the error. We should ease this (simply to make the life also for ourselves a little bit easier).
I would prefer something like this:
invalidPattern = "abc)def"
try:
regexPattern = re.compile(invalidPattern)
except Exception as reason:
print(f"Exception: '{reason}' in pattern '{invalidPattern}'")
Result:
Exception: 'unbalanced parenthesis at position 3' in pattern 'abc)def'
It seems that parameter names are interpreted as regular expression immediately:
causes:
'multiple repeat at position 60
causes:
'multiple repeat at position 60
causes:
'unterminated character set at position 60
causes:
'missing ), unterminated subpattern at position 74
causes:
'unbalanced parenthesis at position 60
Later a naming convention check should prevent the users from using such names, but nevertheless: Key names can for sure be computed with the help of regular expressions, but the names themself should not be interpreted as regular expression (what would be a use case for that?).
Similar to (already solved) issue: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/251