Can't change Image sprite because in rebuild loop?

I’ve combed the internet and found almost no one else with the same issue which is odd…
All I’m trying to do is programmatically change the sprite property of an Image component of a UI element. This is the code I’ve got:

quickAccessBar.transform.GetChild(0).GetComponent<Image>().sprite = common;

I have checked, there is a child of quickAccessBar, it has an Image component attached, and common is a sprite variable and references a texture that is imported as a Sprite. That all is there. Here are the errors i’m getting:

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.UI.ICanvasElement].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/CanvasUpdateRegistry.cs:107)
UnityEngine.Canvas.SendWillRenderCanvases ()

And this second error happens for almost EVERY UI element in the scene:

Trying to remove Image (UnityEngine.UI.Image) from rebuild list while we are already inside a rebuild loop. This is not supported.

Any idea what’s going on?

I have tried and failed at replicating the error in another unity scene. Any idea what this rebuild list issue is?

Figured it out. For some reason I just needed to set the public sprite that i’m changing to (the one called “common”) to “none”, and then drag the sprite I want in to the public field again. For some reason Unity thought it was a Texture2D, not a sprite. Even though I had set the import settings to Sprite.