Would be nice if they fixed this bug... Still present in Pro 3.0 and got demoted to "Will not be addressed."
You cannot publish a layer to AGOL if the "Shape" field is hidden, and there doesn't appear to be any way to check if that's the case before running the tool. It's not the end of the world though, you just have to handle this error:
arcgisscripting.ExecuteError: ERROR 001272: Analyzer errors were encountered ([{"code":"00123","message":"Shape field is not visible","object":"layer_name"},{"code":"00102","message":"Selected layer does not contain a required layer type for web feature layer","object":"map_name"}]).