Terrain:height_above_terrain(true) retuns nil

ArduPlane V4.2.3 (55685c43)
rangefinder is working.
This code is sourced from \ardupilot\libraries\AP_Scripting\examples\fw_vtol_failsafe.lua and \ardupilot\libraries\AP_Scripting\examples\param_get_set_test.lua

function update()
local terrain_height = terrain:height_above_terrain(true)
gcs:send_text(0, string.format("terrain_height:%i ",terrain_height))
return update, 1000
end
return update()

Sources (not sure if this is helpful)

fw_vtol_failsafe 133-116

local terrain_height = terrain:height_above_terrain(true)
local threshold = param:get(‘Q_FW_LND_APR_RAD’)
if dist < threshold and (terrain_height and (terrain_height < LOW_ALT_THRESH:get())) then
gcs:send_text(0, “Failsafe: LANDING QRTL”)

param_get_set 34-36 (value is an float)

local value = param:get(‘SCR_ENABLE’)
if value then
gcs:send_text(6, string.format(‘LUA: SCR_ENABLE: %i’,value))

from docs.lua

function terrain:height_above_terrain(extrapolate) end
—desc
@param extrapolate boolean
@return number|nil

from bindings.desc

singleton AP_Terrain method height_above_terrain boolean float’Null boolean

working correctly this function should return an float. How do I troubleshoot this?