After a few months of the tailgate operating without problem the problem returned.
This time I spent a bit of time looking at each component. The lock operated but was not securing the tailgate. When closed manually the lock engaged so it wasn't the mechanism.
So I tried something I should have done in the first place, I looked at the manual adjusters/stops on the tailgate itself. They looked to be quite extended so I dialled them in a few turns. Then tested the tailgate... which then worked perfectly... and again, again, all good. My own Homer Simpson moment. It never occurred to me to check the adjustment as I have never ever had to do that before. One was a bit loose which suggest why it worked some times and not others. The other needed a bit of effort to turn.