This is not a bug, yaks are considered enemies – though, they are more neutral and will only attack if you attack them first.
You should acquire glasses with the findEnemies and findNearest methods to make this level easier. Then you can use something like:
var enemy = this.findNearest(this.findEnemies().filter(function (enemy) {
return enemy.type !== 'sand-yak';
}));
if (enemy) {
// ...
}
Of course, it is still possible to do the level with just findNearestEnemy, but it may be more complicated. For instance, you can find the nearest enemy, and if it is an yak then check the distance to it and if it is too close then walk away from it.