Accessing an upload field without a property in a template crashes

See this topic

Template does

{%-if "w{step_1_field_3}" == "" -%}

where step_1_field_3 is an upload field.

Crashes here in lib/custom_wizard/mapper.rb line 257

if opts[:template] && CustomWizard::Subscription.subscribed?
  template = Liquid::Template.parse(string)
  string = template.render(data)

Changing it to

{%-if "w{}" == "" -%}

resolves this.

I have tried to force an error in other ways, but couldn’t find those.

I guess a quick fallback safeguard for this would just be a matter of

template = Liquid::Template.parse(string) rescue "There is an error in your template"

although it would be better if we were able to do a check for this at the moment the wizard is being saved by the admin.

@angus could you add a check or an exception handler so that it doesn’t error 500 ?

There is actually already a check for liquid formatting when the template is saved

The issue here is the interpolation of the object into the output. For review

1 Like