FusionAuth / fusionauth-issues

FusionAuth issue submission project
https://fusionauth.io
91 stars 12 forks source link

Preview Functionality does not work with Registration Pages with consents. #2196

Open jobannon opened 1 year ago

jobannon commented 1 year ago

Preview Functionality does not work with Registration Pages with consents.

Description

A clear and concise description of what the bug is.

Affects versions

List the version you are running, and any other versions you have attempted a recreated.

Steps to reproduce

Steps to reproduce the behavior:

  1. Add a consent to a registration workflow (advanced registration pages)
  2. Try and preview this registration page
  3. Get the following error
A FreeMarker exception occurred.

Blamed expression: consents
Line number: 927
Column number: 27
End column number: 34
Theme Id: 75a068fd-e94b-451a-9aeb-3ddb9a3b5987
Template name: /_helpers.ftl

Message:
The following has evaluated to null or missing:
==> consents  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" at line 927, 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: #local checked = consents(field.conse...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "checkbox_list" at line 927, column 9]
    - Reached through: @checkbox_list field=field id="${fiel...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "customField" at line 1029, column 7]
    - Reached through: @helpers.customField field, field.key...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 78, column 15]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "main" at line 193, column 11]
    ~ Reached through: @helpers.main title=theme.message("re...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 44, column 5]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "body" at line 132, column 3]
    ~ Reached through: @helpers.body  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 39, column 3]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "html" at line 31, column 3]
    ~ Reached through: @helpers.html  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 20, column 1]
----

FreeMarker template error:
The following has evaluated to null or missing:
==> consents  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" at line 927, 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: #local checked = consents(field.conse...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "checkbox_list" at line 927, column 9]
    - Reached through: @checkbox_list field=field id="${fiel...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "customField" at line 1029, column 7]
    - Reached through: @helpers.customField field, field.key...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 78, column 15]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "main" at line 193, column 11]
    ~ Reached through: @helpers.main title=theme.message("re...  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 44, column 5]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "body" at line 132, column 3]
    ~ Reached through: @helpers.body  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 39, column 3]
    ~ Reached through: #nested  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/_helpers.ftl" in macro "html" at line 31, column 3]
    ~ Reached through: @helpers.html  [in template "##75a068fd-e94b-451a-9aeb-3ddb9a3b5987##templates/oauth2/register.ftl" at line 20, column 1]
----

Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
    at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
    at freemarker.core.UnexpectedTypeException.newDescriptionBuilder(UnexpectedTypeException.java:85)
    at freemarker.core.UnexpectedTypeException.(UnexpectedTypeException.java:63)
    at freemarker.core.NonMethodException.(NonMethodException.java:74)
    at freemarker.core.MethodCall._eval(MethodCall.java:67)
    at freemarker.core.Expression.eval(Expression.java:101)
    at freemarker.core.ExistsExpression._eval(ExistsExpression.java:49)
    at freemarker.core.Expression.eval(Expression.java:101)
    at freemarker.core.Expression.evalToBoolean(Expression.java:177)
    at freemarker.core.Expression.evalToBoolean(Expression.java:163)
    at freemarker.core.AndExpression.evalToBoolean(AndExpression.java:36)
    at freemarker.core.BooleanExpression._eval(BooleanExpression.java:30)
    at freemarker.core.Expression.eval(Expression.java:101)
    at freemarker.core.Assignment.accept(Assignment.java:134)
    at freemarker.core.Environment.visit(Environment.java:334)
    at freemarker.core.Environment.visit(Environment.java:376)
    at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:291)
    at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271)
    at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244)
    at freemarker.core.Environment.visitIteratorBlock(Environment.java:644)
    at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876)
    at freemarker.core.Environment.invokeMacro(Environment.java:812)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84)
    at freemarker.core.Environment.visit(Environment.java:334)
    at freemarker.core.Environment.visit(Environment.java:340)
    at freemarker.core.Environment.visit(Environment.java:376)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876)
    at freemarker.core.Environment.invokeMacro(Environment.java:812)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:291)
    at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271)
    at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244)
    at freemarker.core.Environment.visitIteratorBlock(Environment.java:644)
    at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
    at freemarker.core.Environment.visit(Environment.java:334)
    at freemarker.core.Environment.visit(Environment.java:376)
    at freemarker.core.Environment.invokeNestedContent(Environment.java:620)
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876)
    at freemarker.core.Environment.invokeMacro(Environment.java:812)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeNestedContent(Environment.java:620)
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876)
    at freemarker.core.Environment.invokeMacro(Environment.java:812)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeNestedContent(Environment.java:620)
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    at freemarker.core.Environment.visit(Environment.java:370)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876)
    at freemarker.core.Environment.invokeMacro(Environment.java:812)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84)
    at freemarker.core.Environment.visit(Environment.java:334)
    at freemarker.core.Environment.visit(Environment.java:340)
    at freemarker.core.Environment.process(Environment.java:313)
    at freemarker.template.Template.process(Template.java:383)
    at org.primeframework.mvc.freemarker.DefaultFreeMarkerService.render(DefaultFreeMarkerService.java:76)
    at org.primeframework.mvc.action.result.AbstractForwardResult.execute(AbstractForwardResult.java:92)
    at org.primeframework.mvc.action.result.DefaultResultInvocationWorkflow.perform(DefaultResultInvocationWorkflow.java:105)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.scope.DefaultScopeStorageWorkflow.perform(DefaultScopeStorageWorkflow.java:60)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.action.DefaultActionInvocationWorkflow.perform(DefaultActionInvocationWorkflow.java:64)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.message.DefaultMessageWorkflow.perform(DefaultMessageWorkflow.java:50)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.validation.DefaultValidationWorkflow.perform(DefaultValidationWorkflow.java:45)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.security.DefaultSecurityWorkflow.perform(DefaultSecurityWorkflow.java:79)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.parameter.DefaultPostParameterWorkflow.perform(DefaultPostParameterWorkflow.java:49)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.content.DefaultContentWorkflow.perform(DefaultContentWorkflow.java:74)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.parameter.DefaultParameterWorkflow.perform(DefaultParameterWorkflow.java:58)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.parameter.DefaultURIParameterWorkflow.perform(DefaultURIParameterWorkflow.java:92)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.scope.DefaultScopeRetrievalWorkflow.perform(DefaultScopeRetrievalWorkflow.java:50)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.action.DefaultActionMappingWorkflow.perform(DefaultActionMappingWorkflow.java:113)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.security.DefaultSavedRequestWorkflow.perform(DefaultSavedRequestWorkflow.java:65)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.cors.CORSFilter.doFilter(CORSFilter.java:171)
    at org.primeframework.mvc.cors.CORSRequestWorkflow.perform(CORSRequestWorkflow.java:63)
    at org.primeframework.mvc.workflow.SubWorkflowChain.continueWorkflow(SubWorkflowChain.java:50)
    at org.primeframework.mvc.workflow.DefaultMVCWorkflow.perform(DefaultMVCWorkflow.java:108)
    at org.primeframework.mvc.PrimeMVCRequestHandler.handle(PrimeMVCRequestHandler.java:72)
    at io.fusionauth.http.server.HTTPWorker.run(HTTPWorker.java:50)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Expected behavior

Preview functionality should work in all cases.

Screenshots

If applicable, add screenshots to help explain your problem.

Platform

dev

Community guidelines

All issues filed in this repository must abide by the FusionAuth community guidelines.

Additional context

Add any other context about the problem here.

MPH-DZP commented 1 year ago

We have a similar problem when rendering consents in our AccountEdit template. When it executes [@helpers.customField field=field key=field.key autofocus=false placeholder=field.key leftAddon="false"/] for a consent, the consent label is shown correctly but is prepended by ">A FreeMarker exception occurred. See the FusionAuth Event Log for additional details.

If it helps, our helpers config's section [#macro customField field key autofocus=false placeholder="" label="" leftAddon="true"] containing conditionals like [#if field.key == "consents['someConsentIdHere']" ] <label for="${fieldId}">${theme.message('registration.data.someIdInMessagesConfigHere')}</label>