Happened to me on my world on 1.21.5, but probably due to mod shenanigans. Fixed it with the methods listed in the thread and I figured I'd put everything in one place for the next poor soul.
Backup your save. Seriously it saved my butt here.
Load your save and go to where you want the trader to spawn. (You could do this first! I am not your father.)
Set your gamemode to creative with '/gamemode 2'
Flag the story system to spawn the trader on your location with '/setstorystrucpos treasurehunter [USERNAME]'. Then enter '/setstorystrucpos treasurehunter [USERNAME] true' to confirm.
Delete the chunk under you with '/wgen delr 0'
You wont be able to move so turn flying+no clip on by hitting F3 twice.
Move around the chunk to get it to spawn in.
You should have your trader! Ignore the set story command's spiel about using a radius of 10 for the delr command, as that is huge and the trader is very small. Revert to survival with '/gamemode 1'