• General Chat
  • Dealing with missing nodes and invalid path errors

I get this set of errors printed out in the console when I open my project:

ERROR: Cannot get path of node as it is not in a scene tree.
   At: scene/main/node.cpp:1642
ERROR: (Node not found: "" (relative to "").)
   At: scene/main/node.cpp:1371
ERROR: ViewportTexture: Path to node is invalid.
   At: scene/main/viewport.cpp:69
ERROR: Cannot get path of node as it is not in a scene tree.
   At: scene/main/node.cpp:1642
ERROR: (Node not found: "" (relative to "").)
   At: scene/main/node.cpp:1371
ERROR: ViewportTexture: Path to node is invalid.
   At: scene/main/viewport.cpp:69

And similar is printed out again when I run the project. I'd like to eliminate them but there's no info that points to their exact origin. I manually checked suspicious places but couldn't find anything problematic. How do we deal with this?

I've sometimes seen errors like that when script files have been deleted, but are still open in the editor. Can you try closing all scripts in the editor script tab an then try playing again?

No difference, unfortunately. I can't figure out if this is a Godot bug or there's junk in my project. I had quite a few viewport textures plugged into materials, and afterwards moved the viewports up and down in the scene tree hierarchy. However I tried to clean everything up but these errors persist. Could it be some dollar-prefixed node paths in scripts? Sadly, the printout is not informative at all.

Your project file may be corrupted. Try opening the godot.project file in a text editor and see if anything looks weird. I had this happen before when trying to sync a project (via git) between Linux and Windows. The project file is human readable, so it should be fine to edit.

Project file seems fine. It's only 75 lines long. Nothing there that suggests corruption or even related to node paths.

I don't think scripts run when you open a project, so it's probably not your code. My guess is that there is a null reference to some resource that was deleted, and that broken link is still in some node on your project. Though Godot is usually pretty good about cleaning those up itself, that's the only thing I can think of.

Yeah, it looks like that. I'll put some more effort in hunting it down... Having a some sort of cleanup tool for situations like this would be useful.

Based on the error log, it looks like it might be one of the ViewportTexture resources is having issues getting a path to the Viewport node at start up.

I remember this used to be an issue in Godot 3.0 if you created a ViewportTexture through the Godot editor. The way I remember working around it was setting the ViewportTexture through code instead in _ready, though it's been awhile since I've encountered the issue. If you are using ViewportTextures, I would check to see if deleting the ViewportTextures in the editor and then assigning them to the necessary nodes through code fixes the issue using something like node.texture = $Viewport.get_texture(). I would highly recommend making a backup first though, so nothing is lost if anything goes wrong and/or it doesn't fix the issue!

If you are not using ViewportTextures anywhere, then I'm at a loss at what could be causing the issue. As you mentioned, the error log doesn't really point to anything conclusive :sweat_smile:

@TwistedTwigleg It's most certainly somehow related to viewport textures. I use a bunch of them and most are assigned through code. Some are assigned in editor. I had some that were assigned in editor that ended up with bad node paths but I unassigned all such cases that I could find. Will try what you suggest and report what happened.

Right. It happens when you assign a viewport texture (to say sprite) but you don't provide a path to viewport. When I was cleaning up I just removed viewport paths (that little broom icon) but I left the actual ViewportTexture alive. This turns path field into a button that says "Assign...". So if things are left in this state the errors will be printed. If I completely delete the ViewportTexture then errors disappear.

I had two such cases. Three error lines are printed per one unassigned viewport.

This should be handled more gracefully. Either don't print any errors if viewport path is not assigned (as opposed to actually invalid path) or explicitly say the viewport is not assigned instead of saying the path is invalid. This then should be a warning, not an error imho.

You might want to open a issue report on this perhaps if one doesn't already exist.

Looking into it... Some similar issues have been reported with more specific problems regarding the viewport path in ViewportTexture object. They all have problems when path is actually assigned. But this is more generic. Engine should simply differentiate between a bad path and a non-existing one.

a month later