While water sitting in pipes for long periods of time can be a breeding ground for bacteria the bacteria has to come from somewhere. Most bacteria that is found in municipal water supplies is harmless to humans.
I have seen (and smelled) water that had been in wet fire suppression sprinkler lines that was almost black and stank to high heaven. I wouldn't have wanted to drink that water but I don't know if doing so would have necessarily harmful. The same is true of water that had been in a heating system for many years.
Municipalities will often flush the main lines by opening fire hydrants and letting the water flow for anywhere from a couple of minutes to as much as a half hour or more if the hydrant is at the end of a main line.
In a residence I don't think there would be any problem from air chambers although if there was a long length of "dead ended" pipe that was for an addition to the house I would probably flush that pipe for several minutes before drinking any water from the end.
If you have a well please ignore this post.