When new information exposes issues with the current piece of work in a sprint, you discuss it, and then change whatever part of the plan no longer makes sense given the new information.
Will it mess up the numbers? Absolutely, but only for that piece. And as a result of the change of plans being entered into the current sprint (with something perhaps bumped to make room, or maybe the work itself bumped to a later sprint to give more time to plan for the new challenges) you already have a new estimate. And you have a paper trail of what happened and how you dealt with it.
Your velocity goes down and you lose some predictability, but your agility goes up because you can adjust instantly to new challenges. None of these tools are a panacea; you have to thoughtfully decide which trade-offs will offer the greatest benefit for your particular project.
The "deadlines" shouldn't be thought of as hard deadlines. They're estimates of what you expect to have done at the end of some arbitrary period. Your accuracy in this should be measured statistically over time. If it turns out that you're consistently under or over, you adjust how you estimate. Ideally you want your estimates to average out to break-even over the course of a year. The point isn't to be able to determine exactly how much work you'll do, but rather to determine with a high degree of confidence (80%? 90%?) when the work will be done, with the understanding that it's not guaranteed (i.e. it's a point statistic). It's a planning tool, not a performance measure (the moment you treat it as a performance measure, it becomes useless due to the cobra effect).