Unfixable variable with invalid type

Pretty severe bug I just found: if you copy/paste a Set node for a blueprint struct from a blueprint in one project, to a blueprint in another project that doesn’t have that struct, and then rightclick the Set node and “create variable”, the blueprint cannot be compiled and the new (invalid) variable can’t be deleted.

Repro:

  • Create a project “Project1”
  • Create a custom Blueprint struct “SomeStruct”
  • Create an actor Blueprint
  • Add a variable called SomeVariable of type SomeStruct to the actor Blueprint
  • Place a Set node for SomeVariable
  • Create a project “Project2”
  • In Project2, create an actor Blueprint
  • Copy the Set SomeVariable node from Project1 and paste it into your blueprint in Project2
  • Right-click on the pasted Set SomeVariable node and select “Create variable ‘SomeVariable’”
  • Attempt to compile the blueprint

You can’t compile because you get the error “The variable SomeVariable declared in has an invalid type Structure”. You can’t delete the variable because it’s invisible in the variables list. Hope you have a backup because otherwise this blueprint is broken forever.

3 Likes

While this is clearly undesired behaviour, it does sound like a marginal use scenario. Why would you even try doing that in the first place? xD Structs are so fragile as they are, no wonder this does crazy things.

Nice catch anyway. +1

Hello ,

We are using a new bug submission form. Please navigate to the link below for more information.

Link: Unreal Engine Bug Submission Form - Announcements - Epic Developer Community Forums

Make it a great day

I just ran into a similar issue with structs. One struct suddenly became unusable (maybe corrupted?) after an editor restart and would not even save. I wasn’t copying between projects or anything. I created a similar struct and deleted the first one, replacing its references with the similar one. Variables in blueprint classes that had the struct type suddenly vanished and could not even be deleted. The blueprint classes wouldn’t compile either.

2 Likes

If in 4.19.1 you duplicate the BP there is a message that pops up asking if you want to delete the variable, if you delete it the BP will work. I had the same error when I moved 4.18.2 to 4.19.1

2 Likes

Something similar happened to me in 4.20.3. I made a struct in C++, had it wired in some BPs, then added 2 elements to the struct and compiled. The hot-reload kicked in and one of my variables threw an error saying “The variable test declared in ___ has an invalid type Map of Floats to Structures”. The variable “test” now won’t appear in the variables list and I can’t get rid of it or change it and the app keeps erroring out. :frowning:

Unfortunately this doesn’t work in 4.20.3 :frowning:

still works on 4.21.2
All you need to do is duplicate that BP then delete the invalid variable. Then you’ll have to delete the original and replace it with the new one.

This worked for me too, but I instead restarted the project and I got a notification asking if i’d like to delete the invalid variables. Thanks

I was struggling with this issue recently and i found working solution for me, thought u may still need answer :slight_smile:

  1. Go to your blueprint and create exatcly same variable (same type and name)
  2. Save blueprint and project.
  3. Restart project
    Now you should not have the notification that you had launching project before.
  4. Go to BP and delete that variable
  5. Save blueprint and project
  6. Restart project

In my opinion variable was still there, but was not visible (bug). Creating exaclty same variable made it “visible” as it was the same variable.

Engine version 4.21. Solution worked for me :slight_smile:

2 Likes

Same error message, different steps to reproduce:

  • Define a C++ struct in a plugin
  • Expose that struct as a variable to a Blueprint
  • Rename the plugin through your IDE (because you hate yourself)
  • Run your project

To fix, I deleted any reference to the old struct, saved the blueprint (note that it still doesn’t compile at this point), exited and re-ran the editor, then recreated references to the struct as needed in BP.

It seems this is now fixed automatically by Unreal on project re-open, as DarkWave0 points out above.

So don’t panic (especially if you have source control, and you should definitely have source control) - save the BP even though it’s not compiling and quit the editor.

On restart you will get a message that your BP has an invalid struct variable, and asking if you’d like to remove it. Just select Remove, and continue.

1 Like

Hi, using Unreal 5.0.3, tried restarting the project, didn’t help.

I had this problem with version 5.0.3 when I wanted to migrate blueprints to another project that used certain structures. However, when I restarted Unreal and tried to reopen my class, it displayed a message asking me if I wanted to delete the non-existent variables. All I had to do was click “OK” and it worked.

If anyone is still having this problem in version 5.2. Right-click on the blueprint > Asset Actions > Reload (Under advanced). You should get a popup asking if you would like to delete the variables of invalid type. Click Okay.

4 Likes

This was the solution for me. Thank you.

In my case, reloading that asset worked fine, after compiling the bp

My solution to fixing a ported struct was changing a variable in the struct itself, in my case it was a character reference which needed to be changed to one in the new project. After saving the struct and recompiling the blueprint affected it made the structs reappear in variables tab and made them usable again.