Going to add to this because I just hit the same issue and it took me more googling than I expected to fix it.
First up, the solution:
Go into Project Settings > Maps & Modes > Default Modes and set the Default GameMode to GameModeBase.
Run a build - This part may be optional, but I ended up doing it just to make sure I could build with the default Game Mode.
Go back into Project Settings > Maps & Modes > Default Modes ans set Default GameMode back to whatever your Game Mode should be.
Run another build. The build should be successful this time.
The Cause:
The reason I encountered this issue is because I re-arranged parts of my folder structure, and moved my Game Mode Blueprint from the base content directory into a subfolder. This appears to throw off UE because the system keeps a redirect reference in memory. Attemping to change from the same gamemode by just toggling the dropdown didnt work, I had to change it, build, then change it back and the system was happy then.
The best I can summarise is that by changing it and forcing the build, it forced the editor to remove its previous reference to the old location and then update it to the new one when I selected it once again.
sometimes when you make some changes
and they do funny things in a build
it helps to delete the saved and intermediate folders
that causes it to fully rebuild everything
I found a solution by ,Fixing up redirectors, capture thumbnail and clear for struct asset, also re defining variable Don’t delete just select the struct again