Template variable warning error

Hello. Can someone help troubleshoot why I am getting this warning?

error

Template variable warning: 'delivery' is undefined when rendering '{% set today = as_timestamp(now() + timedelta(days = 11))|timestamp_custom('%-m/%d/%Y', true ) %} {% if delivery | trim == "" %} {% set delivery = value_json.MAJOR_JP.jcb[ today ] %} {% endif %} {{ delivery }}'

sensor:

  - platform: command_line
    name: Deliveryin2week
    command: 'cat /config/www/data/days.json'
    scan_interval: 14400
    value_template: >
      {% set today = as_timestamp(now() + timedelta(days = 11))|timestamp_custom('%-m/%d/%Y', true ) %}
      {% if delivery | trim == "" %}
      {% set delivery =  value_json.MAJOR_JP.jcb[ today ] %}
      {% endif %}
      {{ delivery }}

First you test if delivery, then you set delivery. On the first it is not yet set.

It seems I did not need this line to begin with.

{% if delivery | trim == "" %}