A BLESSING IN DISGUISE = an unlucky event or situation that results in an (unforeseen) positive outcome.
“Getting caught out in the rain turned out to be a blessing in disguise – if I hadn’t been there, I wouldn’t have met my future wife.”