fix Issue 10326 - Change old `invariant` usage to error

deprecation -> error