Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event context not working for repeater objects where the repeater object is specified using square brackets "[ ]" #247

Closed
gunnar-enerin opened this issue Feb 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@gunnar-enerin
Copy link
Contributor

When using repeaters where the repeater object is specified using square brackets, by for example
@{example_state_object[sub_object]}, Evaluator.evaluate_field() in core.py raises an error because the string passed to json.loads(replaced) does not contain valid json. This is caused by the regular expression not recognising the square brackets.

The use case where specifying the repeater object using square brackets is for instance with nested repeaters where a child repeater object needs to be specified by either the key or value of a parent repeater object.

This can be fixed by changing the regex line in the Evaluator class in core.py from:
template_regex = re.compile(r"[\\]?@{([\w\s.]*)}")
to
template_regex = re.compile(r"[\\]?@{([\w\s.\[\]]*)}")
to allow the recognition of square brackets.

I have tested that this fix actually resolves the issue, but I don't know whether it introduces any risks or other side effects.

@mmikita95
Copy link
Contributor

mmikita95 commented Feb 21, 2024

Thanks for spotlighting this issue and offering a solution — it is most appreciated!

Upon examination, your proposed fix seems clear of risks or side effects. The square brackets are indeed anticipated within the expression and are processed accordingly by parse_expression later on.

I'd suggest that you submit a PR, to highlight your contribution. However, if you'd prefer not to, I could do it on your behalf, just let me know!

@mmikita95 mmikita95 added the bug Something isn't working label Feb 21, 2024
@mmikita95
Copy link
Contributor

#257 is merged into dev branch, so we can consider this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants