GameObject.Find() sometimes fails, is that okay?

I have several invisible locations that my player has to walk over to complete the game. When she touches one, the next will highlight. I do this by using Find() to find the current helper, ie:

var currentGoalHelper = GameObject.Find("Goal"+currentMissionNum+"Helper");

This works great until the final goal is reached because obviously there are no more to find, so I get a Unity error in the console. Is this okay? Or should I be doing some sort of check first? Or is it okay if a Find() fails? I assume sometimes it just won’t find anything right?

use an if statement to constrain the code, if currentGoalHelper is null skip the code that is associated withe currentGoalHelper, if it is not null, do what you normally do.

// .. code
if (currentGoalHelper) {
... code that uses currentGoalHelper
}

// .. code

Yes it’s okay if the find fails.
To keep your console clean, you can wrap the var currentGoalHelper with a check before trying to access it like :

var currentGoalHelper = GameObject.Find("Goal"+currentMissionNum+"Helper");

if (currentGoalHelper){
    //Execute code
}else{
    //Don't access currentGoalHelper as it is null
}

Keep in mind that the GameObject.Find function will loop across all your gameObjects in the scene. I would personally keep a reference to your currentMissionNum in a static class to avoid running the GameObject.Find every time you need to access the currentMissionNum.

hope this helps!