We recently had an issue where a Ruby gem that was part of our project was taking action based on the value of an environment variable. This behavior was not mentioned anywhere in the documentation and completely tripped us up.
The behavior difference was subtle and totally silent.
At best the library was expecting us to follow an implied convention they were dictating, at worst it was a disaster waiting to happen.
Or is this a failure to exercise our code extensively enough and modify environment variables with more care? How would you guard against this sort of issue?