You found the problem - loose fitting pigtail in to the truck plug.
It's a known issue that some pigtails are not made to the correct spec size (diameter) and fit loosely in the OEM truck plug.
Some brands of pigtails are better than others.
I had the problem all the time with the "check trailer wiring" warning on the DIC.
I made a comment about it to someone, and he described the problem. I changed the trailer cord to one that fits tighter, problem was solved.
I thing there's even a bulletin that GM published about this because so many people were trying to blame the truck, when in fact it was the crappy cord