It turned out that the problem was a single line of code written by a junior developer who has since been fired!