Letting the cat out of the bag:
I always understood that this one came from the custom of selling a piglets in a bag at a fair. An unscrupulous seller might put a cat in the bag instead of a piglet, and so when you inspected your purchase, you may discover this secret, by letting the cat out of the bag.