[Debug] Added check to make sure context array is not empty

Fixes #8703