Error: Condition "!valid" is true

Godot Version

4.3.beta1.mono

Question

I had this error pop up randomly and I’m not quite sure where it’s coming from. I am using the 4.3 beta version so I’m assuming it has something to do with that. I just haven’t seen any mention of others running into this error and it only just appeared this morning after a few weeks of using this version.

E 0:00:01:0230   instantiate: Condition "!valid" is true. Continuing.
  <C++ Source>   scene/resources/packed_scene.cpp:534 @ instantiate()

I get this error three times in sequential order at the start of the scene. I’ve tried removing all scenes in the played scene that is even remotely responsible of instantiating any of my own assets, but the error persists. It doesn’t appear to be breaking anything, so while it isn’t “mission critical” to have this solved ASAP, it is a little annoying seeing it constantly appear each time I run a scene. Just curious if anyone has run into this particular issue.

Much appreciated!

So in the Debugger you don’t get a stack trace? Also please show us your instantiation code.

Yeah, there isn’t anything for the stack trace. It’s the weirdest thing. I have a screenshot of what I get in the debugger below.

image

can u plz show me ur code of you instantiating a scene?

Here’s a snippet of some code instantiating some inventory slots for the player. Initialized() is called on ready. All other code involved with instantiating follows the same pattern.

using Godot;
using Godot.Collections;
using System;

public partial class ActiveInventoryDialog : Control
{

  [Export] private GridContainer gridContainer;
  [Export] private PackedScene InventorySlot;
  
  private Array<inventory_slot> activeSlots = new();
  
  public override void _EnterTree()
  {
      SetVisibility(false);
      Connect(SignalName.InvToPlayerUpdate, new Callable(RootUI.Instance, RootUI.MethodName.UpdatePlayerInventory));
      RootUI.Instance.Connect(RootUI.SignalName.AddItemToActiveInventory, new Callable(this, MethodName.AddItem));
      RootUI.Instance.Connect(RootUI.SignalName.InitializeActiveInventory, new Callable(this, MethodName.Initialize));
      RootUI.Instance.Connect(RootUI.SignalName.ToggleActiveInventoryUI, new Callable(this, MethodName.ToggleActiveInventoryDialog));
  }
      
  internal void Initialize(int index)
  {
      //Initialize active pocket inventory of the player based on the player's active inventory size
      //Will create number of pockets based on the index passed into the initialization method
     for(int i = 0; i < index; i++)
     {
      inventory_slot newSlot = InventorySlot.Instantiate<inventory_slot>();
      newSlot.itemSlotType = inventory_slot.ItemSlotType.GENERAL;
  
      activeSlots.Add(newSlot);
      gridContainer.AddChild(newSlot);
  
      newSlot.Connect(inventory_slot.SignalName.InventorySlotsUpdate, new Callable(this, MethodName.UpdateActiveInventory));
      newSlot.Connect(inventory_slot.SignalName.InventorySlotSelected, new Callable(this, MethodName.GetSlot));
     } 
  } 
}

as a note, this is packed_scene.cpp line 533

Array array = dnp.base->get(dnp.property, &valid);

at the moment this means nothing, but this is where the error is generated

well, i don’t know how to reproduce the error. and i am unsure what exactly the error in c++ means.

if this was my project, i would use an extension method to track down where the error is.

any time a packed scene is instantiated, the resource path is printed. optionally you could include the file name and line number.

scroll through the console output, and check out the resource path/file/line above each instance of “instantiate: condition “!valid” is true. continuing.”

Not the best fix but it is what i would do.


using Godot;
using System;

public static class MyHelperFunctions {
	public static T MyInstantiate<T>(this PackedScene a_packed_scene, string a_file_line = "") where T : Node {
		GD.Print(a_packed_scene.ResourcePath, " ", a_file_line);
		T v_var = a_packed_scene.Instantiate<T>();
		return v_var;
	}
}

public static class FileLine {
	public static string Get([System.Runtime.CompilerServices.CallerFilePath] string a_file = "", [System.Runtime.CompilerServices.CallerLineNumber] int a_line = 0) {
		return System.IO.Path.GetFileName(a_file) + " " + a_line;
	}
}


public partial class MySceneTest:Node2D {
	public override void _Ready() {
		PackedScene v_packed_scene = ResourceLoader.Load<PackedScene>("res://Instantiate/csharp/mytestscene.tscn");

		// called extension method (above) MyInstantiate
		v_packed_scene.MyInstantiate<Control>();
		v_packed_scene.MyInstantiate<Control>(FileLine.Get());
	}
}


That is an error caused by having a corrupted NodePath or property export in your loaded scene.

Commonly caused by using export NodePaths or export properties in scripts or animations that point to something that does no exist on scene load or a path that is corrupted in the first place because whatever was targeted got deleted or renamed without the property or path updating.

Basically that function tries to replace the property path with the actual object behind that path after having done the other steps of the scene load and that path resolution fails and triggers this error (the dnp.base->get() tries to get the property from the node and fails).

2 Likes

That did it! What Smix suggested lead me down the correct path.

Essentially, I had a deprecated version of a UI scene buried in some containers on my test scene. I had been editing some code earlier that the old UI was communicating with, and that’s when the errors started appearing. I had thought I removed the old UI already so I didn’t think to check it. In any case, after I got rid of it the errors disappeared! All of this basically means I need to have better Node organization in my scene :upside_down_face:

Thank you both so much for taking the time to look into this! I would’ve just brushed this off since it wasn’t affecting anything at the time, but I’m super happy that I get to keep a clean debugger log. You guys are the best!