Fix type error crash

fixes #1511 on github

This probably wouldn't occur in production under normal circumstances,
but it's harmless to fix it.