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
--minify breaks on JSON since 59.0 #6472
Comments
/cc @anthonyfok |
Hi Regis and Bjørn Erik, Thank you for bringing this to my attention. Unfortunately, partly due to my unfamiliarity with the JSON output feature, or perhaps the JSON test cases that I have on hand are too simplistic, that I am unable to reproduce the error that you are seeing, so please do share a test repo when you have time. Many thanks! |
Yea, I added a quick test for this myself, and it doesn't look like "JSON is broken" is true in the general sense (which would have surprised me), so there must be something "special" about the JSON file used. |
Will try and look into it next week. Thanks a lot. |
here you go @anthonyfok : https://github.com/theNewDynamic/gohugo-6472 Thanks a lot for your patience. |
The error is reported from parse in commit tdewolff/parse@7763141 (between v2.3.5 and v2.3.6): "Improve error messages for NULL and unknown values" So, according to @regisphilibert's MWE (minimal working example) https://github.com/theNewDynamic/gohugo-6472:
or fuller report after I tweaked tdewolff/parse code:
It would appear that somehow Hugo is trying to ask Minify to process HTML as if it were JSON, and before commit tdewolff/parse@7763141, such error was silently ignored by tdewolff/parse. So... But then, it does not seem to explain the error message that @regisphilibert's originally encountered:
As So:
@regisphilibert, I know you are very busy, but, if possible, could you please also try to produce a MWE in order to get the error you see initially, i.e. "unexpected character" on seemingly valid JSON code? @tdewolff, please help take a look and see if you can shed some light on this. Thank you! (Sorry, I am really slow at trying to understand the code, and I have exceeded my quota for today, hence this "progress report" and plea for help.) |
@anthonyfok I just updated the example repo so it compiles with what you requested. Not sure what did it, but it seems to be assigning JSON on RegularPage as well as lists. |
Note to self: In the example that @regisphilibert provided, Hugo apparently calls Minify() from func Transformer() in minifier/minifier.go: return min.Minify(m.m, ft.To(), ft.From(), params) I was going to try to decipher what |
Wow, that was really quick! Thank you so much @regisphilibert!
Hmm... strange, the That p.err = parse.NewErrorLexer("unexpected character", p.r) to p.err = parse.NewErrorLexer("unexpected character"+string(c), p.r) |
What I think is happening is that passing HTML is causing the error (ie. the When the parser finds an error, it registers the |
I have fixed this problem partially in tdewolff/parse@2.3.14 (with tdewolff/minify@2.6.1). What remains is that Hugo parses a generated HTML document by a JSON parser. This can be confirmed by adding:
before line 54 in
Stack trace:
Edit: |
FWIW, I upped from 0.59.1 to 0.61.0 and now --minify is producing malformed AMP HTML Pages.. will turn off until it's sorted out.. |
I'm unable to reproduce this in v0.79.0. Anyone confirm? Edit: I'm testing the example repo from @regisphilibert |
I cannot reproduce the problem with v0.88.1. Closing. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Since 59.0 hugo throws errors when trying to minify JSON files.
It appears the minify lib has been updated to
v2.5.2
with Hugo 59.0 so wondered if that could trigger the issue... b401858I'll try and share a repo later.
Thanks!
The text was updated successfully, but these errors were encountered: