UndefinedError: 'homeassistant.helpers.template.Wrapper object' has no attribute ''

I have written a script that reads the response from a n2yo api call, processes it and populate a sensor entity at the times given in the response. It appears to work fine but I see many warnings in my Core log (extract given below). It reports that there is an error that have occurred 993 times but I do not see any problem in the trace and I don’t understand what is wrong based on the error details.

alias: Get N2YO data
sequence:
  - data: {}
    response_variable: acs3_response
    action: rest_command.n2yo_acs3_request
  - metadata: {}
    data:
      message: "{{acs2_response}}"
    enabled: false
    action: notify.n2yo_acs2
  - variables:
      acs3_status: "{{ acs3_response['status']}}"
  - if:
      - alias: If status == 200
        condition: template
        value_template: "{{ acs3_status|int == 200 }}"
        enabled: true
    then:
      - variables:
          positions: "{{ acs3_response['content']['positions'] }}"
      - variables:
          poscount: "{{positions|length}}"
      - variables:
          thissecond: "{{as_timestamp(now())|round(0)}}"
          timestampmatch: |
            {% for k in range(0,poscount) %}
              {% if (positions[k].timestamp >= thissecond) and (positions[k].timestamp < thissecond + 1) %}
                {{k}}
              {% endif %}
            {% endfor %}
          azimuthnow: "{{positions[timestampmatch].azimuth}}"
          elevationnow: "{{positions[timestampmatch].elevation}}"
      - data_template:
          entity_id: sensor.n2yo_acs3_states
          satlatitude: "{{positions[timestampmatch].satlatitude}}"
          satlongitude: "{{positions[timestampmatch].satlongitude}}"
          sataltitude: "{{positions[timestampmatch].sataltitude}}"
          azimuth: "{{positions[timestampmatch].azimuth}}"
          elevation: "{{positions[timestampmatch].elevation}}"
          ra: "{{positions[timestampmatch].ra}}"
          dec: "{{positions[timestampmatch].dec}}"
          timestamp: "{{positions[timestampmatch].timestamp}}"
          eclipsed: "{{positions[timestampmatch].eclipsed}}"
          k: "{{timestampmatch}}"
        action: python_script.set_state
        enabled: false
      - data_template:
          file: python_scripts/set_state.py
          cache: false
          entity_id: sensor.n2yo_acs3_states
          satlatitude: "{{positions[timestampmatch].satlatitude}}"
          satlongitude: "{{positions[timestampmatch].satlongitude}}"
          sataltitude: "{{positions[timestampmatch].sataltitude}}"
          azimuth: "{{positions[timestampmatch].azimuth}}"
          elevation: "{{positions[timestampmatch].elevation}}"
          ra: "{{positions[timestampmatch].ra}}"
          dec: "{{positions[timestampmatch].dec}}"
          timestamp: "{{positions[timestampmatch].timestamp}}"
          eclipsed: "{{positions[timestampmatch].eclipsed}}"
          k: "{{timestampmatch}}"
        action: python_script.exec
      - repeat:
          sequence:
            - variables:
                thissecond: "{{as_timestamp(now())|round(0)}}"
                timestampmatch: |
                  {% for k in range(0,poscount) %}
                    {% if (positions[k].timestamp >= thissecond) and (positions[k].timestamp < thissecond + 1) %}
                      {{k}}
                    {% endif %}
                  {% endfor %}
                azimuthnow: "{{positions[timestampmatch].azimuth}}"
                elevationnow: "{{positions[timestampmatch].elevation}}"
            - data_template:
                entity_id: sensor.n2yo_acs3_states
                satlatitude: "{{positions[timestampmatch].satlatitude}}"
                satlongitude: "{{positions[timestampmatch].satlongitude}}"
                sataltitude: "{{positions[timestampmatch].sataltitude}}"
                azimuth: "{{positions[timestampmatch].azimuth}}"
                elevation: "{{positions[timestampmatch].elevation}}"
                ra: "{{positions[timestampmatch].ra}}"
                dec: "{{positions[timestampmatch].dec}}"
                timestamp: "{{positions[timestampmatch].timestamp}}"
                eclipsed: "{{positions[timestampmatch].eclipsed}}"
                k: "{{timestampmatch}}"
              action: python_script.set_state
              enabled: false
            - data_template:
                file: python_scripts/set_state.py
                cache: false
                entity_id: sensor.n2yo_acs3_states
                satlatitude: "{{positions[timestampmatch].satlatitude}}"
                satlongitude: "{{positions[timestampmatch].satlongitude}}"
                sataltitude: "{{positions[timestampmatch].sataltitude}}"
                azimuth: "{{positions[timestampmatch].azimuth}}"
                elevation: "{{positions[timestampmatch].elevation}}"
                ra: "{{positions[timestampmatch].ra}}"
                dec: "{{positions[timestampmatch].dec}}"
                timestamp: "{{positions[timestampmatch].timestamp}}"
                eclipsed: "{{positions[timestampmatch].eclipsed}}"
                k: "{{timestampmatch}}"
              action: python_script.exec
            - delay:
                hours: 0
                minutes: 0
                seconds: 0
                milliseconds: 700
          while:
            - condition: template
              value_template: "{{timestampmatch<10}}"

Logger: homeassistant.components.script.get_n2yo_data
Source: helpers/script.py:2058
integration: Scripts (documentation, issues)
First occurred: 00:48:59 (993 occurrences)
Last logged: 22:48:59

Get N2YO data: If at step 4: Repeat at step 6: Error executing script. Error rendering template for variables at pos 1: UndefinedError: ‘homeassistant.helpers.template.Wrapper object’ has no attribute ‘’
Get N2YO data: If at step 4: Error executing script. Error rendering template for repeat at pos 6: UndefinedError: ‘homeassistant.helpers.template.Wrapper object’ has no attribute ‘’
Get N2YO data: Error executing script. Error rendering template for if at pos 4: UndefinedError: ‘homeassistant.helpers.template.Wrapper object’ has no attribute ‘’