FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    FreeMarker error: postMethod variable null in registration verify template

    Scheduled Pinned Locked Moved Solved
    Frequently Asked Questions (FAQ)
    freemarker templates themes registration verification
    1
    2
    17
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FASupportBot
      last edited by

      I'm encountering a FreeMarker template error when users click a verification link, specifically on the registration verify page. The error indicates that the postMethod variable is evaluating to null:

      FreeMarker template error:
      The following has evaluated to null or missing:
      ==> postMethod  [in template "registration/verify.ftl" at line 16, column 30]
      

      The problematic line in my registration/verify.ftl template is:

      [#if verificationId?? && postMethod]
      

      This error seems to occur when the verification link is clicked a second time. The stack trace shows:

      freemarker.core.InvalidReferenceException
        at freemarker.core.NonBooleanException.<init>
        at freemarker.core.Expression.modelToBoolean
        at freemarker.core.AndExpression.evalToBoolean
        at freemarker.core.IfBlock.accept
      

      Is there a recommended way to handle this variable safely in the template to prevent this error?

      If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

      1 Reply Last reply Reply Quote 0
      • F
        FASupportBot
        last edited by

        The postMethod variable can be null or missing in certain scenarios (such as when a verification link is clicked multiple times), causing the FreeMarker template to fail.

        To fix this, you need to provide a safe fallback for the postMethod variable. Update line 16 in your registration/verify.ftl template from:

        [#if verificationId?? && postMethod]
        

        To:

        [#if verificationId?? && (postMethod!false)]
        

        The !false syntax provides a default value of false when postMethod is null or missing, preventing the FreeMarker exception.

        Steps to apply the fix:

        1. Navigate to Customizations → Themes in the FusionAuth admin UI
        2. Edit your theme
        3. Locate the registration/verify.ftl template
        4. Update the conditional check as shown above
        5. Save the theme

        This pattern can be applied to other templates where variables might be null or missing in certain execution paths.

        Why this happens:

        According to the FusionAuth documentation, the postMethod variable is not a standard template-specific variable for the /registration/verify template. It is typically available on other verification templates like /email/verify (where it defaults to true). The registration verify template is rendered when a user clicks the URL from the verification email and the verificationId has expired or is invalid. In these scenarios, postMethod may not be set in the template context, which causes the FreeMarker error when attempting to evaluate it as a boolean.

        Related Documentation

        • Theme Template Variables - Verify Registration - Documents the variables available in the registration verify template
        • Theme Template Variables - Email Verification - Shows that postMethod is documented for email verification but not registration verification
        • Theme Template Variables - Complete reference for all template variables across different templates

        If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

        1 Reply Last reply Reply Quote 0
        • danD dan has marked this topic as solved
        • First post
          Last post