Array index 0 bug

Since upgrading to 4.24.1 all blueprint nodes that get an array(eg Get all widgets of class) throw a warning message similar to this;
Attempted to access index 0 from array ‘CallFunc_GetQueryResultsAsLocations_ResultLocations’ of length 0 in {fileName}

Adding is valid nodes will just make the error throw twice. Once for the is valid and once for the Get.
In previous versions of the engine I don’t get this.
Please guys how can I fix this? I don’t know what to do because all my code uses valid checks before trying to do anything.

First of all… sometimes it does help to actually open a copy of your project in the new versions rather than convert in place (I plead guilty of being lazy myself and just converting in place). Anyway, hopefully you haven’t lost an older working copy that could be useful for troubleshooting, perhaps you just upgraded from 4.24 to 4.24.1 which doesn’t require converting.

So, you mentioned a {filename}, do you mean there is something going on in your C++ code as well (if any?). Could this perhaps be a deprecated function issue… something you are using that is not supported by 4.24 anymore?

Since it would be hard to believe that arrays stopped working in the new version, I’ll say it has something to do in particular with your arrays. As mentioned above it depends on what elements you’re feeding into them and how you obtained them, check if any dependencies or anything very esoteric you’ve done has changed with the new version.

Maybe a screenshot or two, a bit more detail in general, might help people understand where your problem is.

Here is just one example. But every single time I have used an array or a switch I get warning errors. Some I have been able to fix using valid checks. Others I haven’t been able too. What is weird is all the code works and does its job but just throws these errors.

I was able to fix this with a valid check. And I fixed all my arrays be using get valid index before get a copy at the index I want.
I’m still having a ton of trouble with enums and switchs. Because you can’t check if an enum state is valid.
In that particular screenshot yeah its an AI that inherits from a base one and they have multiple components.

Hmmm… in your example above, it just means that the owner Pawn (which I assume it returns as Valid and your Branch executes just fine afterwards - I just can’t see because the picture cuts off) does not have any components of that class. You have to trace this back and make sure it still happens.
Why do you need to get an array of them with GetComponentsByClass()? Why not just get the one you need? Do you have multiple ones on same character? Perhaps because they all inherit from a base one? Can’t tell what BP_BehaviorComponent is, but if it doesn’t have any children classes, then I personally don’t understand why you need to find an array of them.

I’m not sure how but I want to vote that last response as the answer.
I’m not sure why everything was fine but then didn’t work correctly in the newest version.
But I kind of like it this way. It teaches me to validate stuff before calling it. I just wish you could validate enum states before using them for something like a switch.

So it sounds like a design issue. You may have to rethink how you implement your stuff so that you don’t have to check like that all the time.
And yes, when you try to find by “class” where that “class” is a base with multiple children classes, probably best to check for nullptr or that you actually have the derived class you need before trying to access any elements in the return array.
Did you ever figure out though why all this was working in the earlier UE4 version as you said…?

the problem is that the functon GET (an elment in array) is propagate. it mean that some times (but always in my app) it’ll be always calls and there isn’t a way to stop it. usaualy it lead Access violation and crash app then. i’m a little angry to developers because it have left 4 years since without any progress.