Null checking on ctx.token.type before calling indexOf on it.