Looks like you forgot to return here. Thinking on this more, one better option is probably to send the template, but without the task history attached. Instead, say, No Task history could be found (or some suitable message.)