You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I've found an issue with line number reporting in error messages, so I wanted to check if this is expected behavior.
Possible issue: Line numbers in LiquidSyntaxError might be incorrect
Description
I noticed that in some cases with multi-line templates, the line number in LiquidSyntaxError messages might not be showing the actual line where the error occurred.
Steps to Reproduce
fromliquidimportTemplatetemplate_string="""Hello, My name is {{{ name }}"""try:
Template(template_string)
exceptLiquidSyntaxErrorase:
print(f"Error message: {e}")
Expected Behavior
I would expect the error message to show line 2, as that's where the syntax error appears to be.
Actual Behavior
The error message seems to always show line 1 in this case.
Investigation
I've been looking at the error handling in environment.py, and I wonder if this part might be related:
If not, would it make sense to update the line number handling?
Are there any test cases that specifically check for correct line numbers in syntax errors?
Additional Context
I noticed that some test cases in test_malformed.py do handle line numbers correctly, so I might be missing something about how this should work.
I'd be happy to investigate further or help with a fix if this turns out to be a bug. Please let me know if you'd like me to provide any additional information or create a PR.
Thank you for maintaining this great library!
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. It is not intended behaviour. I was failing to pass a line number to some expression parsing functions in multiple place, causing the line number to default to 1.
It still needs a few more tests, but PR #163 should fix this.
This should be fixed in version 1.12.2, now released.
I've been working on improving exceptions and error messages in Python Liquid2 (separate repository). Using the example above, we get the following error message from Python Liquid2.
fromliquid2importrendersource="""\Hello,My name is {{{ name }}"""render(source, name="Bob")
liquid2.exceptions.LiquidSyntaxError: unexpected '{'
-> 'My name is {{{ name }}' 2:13
|
2 | My name is {{{ name }}
| ^ unexpected '{'
Hi there!
I think I've found an issue with line number reporting in error messages, so I wanted to check if this is expected behavior.
Possible issue: Line numbers in LiquidSyntaxError might be incorrect
Description
I noticed that in some cases with multi-line templates, the line number in LiquidSyntaxError messages might not be showing the actual line where the error occurred.
Steps to Reproduce
Expected Behavior
I would expect the error message to show line 2, as that's where the syntax error appears to be.
Actual Behavior
The error message seems to always show line 1 in this case.
Investigation
I've been looking at the error handling in
environment.py
, and I wonder if this part might be related:Questions
Additional Context
test_malformed.py
do handle line numbers correctly, so I might be missing something about how this should work.I'd be happy to investigate further or help with a fix if this turns out to be a bug. Please let me know if you'd like me to provide any additional information or create a PR.
Thank you for maintaining this great library!
The text was updated successfully, but these errors were encountered: