# Blueprints - Not connected execution paths return unexpected value

**URL:** <https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [November 2, 2023, 8:06pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266 "2023-11-02T20:06:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnonyTM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AnonyTM](https://forums.unrealengine.com/u/AnonyTM)\
**Post date:** [November 2, 2023, 8:06pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/1 "2023-11-02T20:06:30Z")

</div>

Hello there, I have just recently started using blueprints and come from a programmer background. I am currently developing a game and love the editor and the concepts of blueprint programing. I have now spent around 100 hourson a project and have created some complicated logic that utilizes many different blueprint classes, interfaces and enums.

**To the problem:**  
So originally I assumed that if an execution path is not connected to a return node within a function, a default value would be returned or at least an error would occur. But recently during some debugging sessions I have noticed that almost all the bugs that I have encountered so far are because some execution pins where not connected to a return node leading to an invalid return value.

What actually happens seem to be that the return value is based on an already existing return node within the same function. I have found the [following Question](https://forums.unrealengine.com/t/blueprint-function-returning-wrong-value/437680) and I understand why this is happening. But my question is, is it possible to have some sort of validation for this in the editor? Either total error and not allowing to compile in the editor, or at least having some sort of possibility to find all “problematic” blueprints?

For now, I can just go and fix the existing problems when I encounter them, but I can imagine I could introduce some bugs due to human error when creating future blueprints. Any help is appreciated, Thank you in advance!

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [November 2, 2023, 10:07pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/2 "2023-11-02T22:07:22Z")

</div>

blueprint functios without any input are totally valid and dont throw errors.  
Are void functions. (a function without a return value)

---

<div class="post-metadata">

**Author:** ![gardian206](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gardian206](https://forums.unrealengine.com/u/gardian206)\
**Post date:** [November 3, 2023, 1:39am UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/3 "2023-11-03T01:39:07Z")

</div>

if the function has a return type/variable then all execution paths should lead to a return node that returns that value

theoretically you should also have functions without a return type/variable also go into a return node.

the reason why it is “technically” OK that not all execution paths of a function go to a return node

- Blueprint Functions are derived from Blueprint Events, and Events don’t actually return they just stop.
- the `Sequence` node exists which means that the blueprint compiler would need to take potentially longer passes (in my mind the blueprint compiler is only really compiling one thing at a time, and I would rather have it take a little longer and not produce nothing/garbage/crashes)

for analyzing blueprints to find if the final node in the execution path of a blueprint function is a return node would probably be done using a Python plugin, or modifying the Engines source, (so for most projects a Python plugin)

---

<div class="post-metadata">

**Author:** ![AnonyTM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AnonyTM](https://forums.unrealengine.com/u/AnonyTM)\
**Post date:** [November 5, 2023, 4:40pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/4 "2023-11-05T16:40:29Z")

</div>

Alright, I was hoping there was a simple way to have a warning about this in the editor but I will take a look. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [November 5, 2023, 4:58pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/5 "2023-11-05T16:58:43Z")

</div>

if it hits a code path that does not return, then the function returns None and you should get some pretty annoying log warnings when you try to access the return value.

BP functions are not based on BP events, blueprint as a whole is a cover of paint put over the old UnrealScript, and events and functions basically are interchangeable except for a few bits here and there.

---

<div class="post-metadata">

**Author:** ![AnonyTM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AnonyTM](https://forums.unrealengine.com/u/AnonyTM)\
**Post date:** [November 5, 2023, 6:26pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/6 "2023-11-05T18:26:42Z")

</div>

**None** would have been good, to be honest… The problem is it can even return true for boolean outputs which was quite unexpected.

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [November 5, 2023, 6:51pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/7 "2023-11-05T18:51:58Z")

</div>

yeah, None basically blows up the comparison operators. And that’s why you get a Blueprint compile warning, and you get a runtime warning in the log when you try to do these things 🙂 If you’re returning a Name or an Object or a Class, then you’ll get a proper ‘None’ result, but otherwise you get … junk.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 5, 2023, 6:52pm UTC](https://forums.unrealengine.com/t/blueprints-not-connected-execution-paths-return-unexpected-value/1358266/8 "2023-12-05T18:52:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
