I also just ran into this problem (influxdb-2.7.5). It seems to be specific to the UI Data Explorer. When specifying a range, unless you explicitly use v.timeRangeStart and v.timeRangeStop (populated by the Time Range selector above the script editor), v.windowPeriod will not be defined and the query will fail with that error.