keycloakify icon indicating copy to clipboard operation
keycloakify copied to clipboard

Error on messagesPerField evaluation in error.ftl

Open abencun-symphony opened this issue 2 years ago • 5 comments

First of all thank you for your active maintenance of this awesome project!

The following exception occurs in error.ftl:

The following has evaluated to null or missing:
==> messagesPerField  [in template "error.ftl" at line 42, column 27]

----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: #if !messagesPerField.existsError??  [in template "error.ftl" at line 42, column 21]

We're not really sure why or how is this happening - but looking at this error message it looks to us that perhaps !messagesPerField.existsError?? should be changed to !(messagesPerField.existsError)?? or a similar expression?

Also, I see that this code seems to be present in other ftl templates and runs fine - maybe it's something configuration-related on our end that we should be paying attention to?

We're running Keycloakify 7.12.8 on Keycloak v20.0.5.

abencun-symphony avatar Jun 27 '23 12:06 abencun-symphony

Hello @abencun-symphony,

Thank you for reporting, be sure I'll adress the issue in good delay.
The exception is only loged by Keycloak but otherwise, the page still works correct?
Can you try with the latest Keycloakify version?
If you still have the error, can you try with 7.11.10?

Thanks in advance

garronej avatar Jun 27 '23 12:06 garronej

I think that the page runs correctly. Will come back with more details. Thank you for a quick response!

abencun-symphony avatar Jun 27 '23 13:06 abencun-symphony

@garronej 7.11.10 and latest don't fix the issue. However I think I've tracked it down and I've opened PR #370 with a potential fix.

abencun-symphony avatar Jun 27 '23 13:06 abencun-symphony

Ohhhh, I see, I did a big mistake.
I got confused between the JavaScript control flow and the FreeMarker control flow.
Writing FTL code that outputs JavaScript is chalenging to reason about.

Anyway, I'm releasing 7.14.2 that should fix the issue. Thanks for reporting!

garronej avatar Jun 27 '23 15:06 garronej

Awesome, appreciate it!

abencun-symphony avatar Jun 28 '23 08:06 abencun-symphony