It is not exactly a rare occurrence but it is certainly a major mistake that could have, nay, should have been identified by your advisors. One of the primary roles of an advisor is to ensure that their students are building their doctoral research on a solid foundation. This is a crucial responsibility as the propagation of errors, which could have easily been rectified, resolved, or circumvented with early intervention, can easily undermine years of rigorous and fastidious research and analysis. l
Other than a waste of your time and their money, however, the only major consequence is demoralization. The severity of the issue and what it will take to redress the situation to get back on track is hugely dependent upon several factors. The discipline and specific area of research, the proportion of prior research that can be repurposed once you've formulated an alternative focus, how quickly you can rebuild your momentum, but mostly it will depend on your own creativity. I don't think your advisors have served you well up to this point but perhaps they could finally make themselves useful, ask them if you can do a cursory examination of any unpublished data generated by former pupils.
I was very creative and hard working in my PhD program and I used the same approach as I always do in life, which is the three-tier strategy. I had work that was bland and boring but would surely satisfy all the requirements for publication but would require dozens of pages of bullshit jargon to church it up enough for a thesis. I also had a very promising project that was novel, interesting, and had the potential to help a lot of people. The third project was what I played around with on the side, used my own money to fund it, and it was a "Hail Mary" pass; high risk but very high reward. I realize you've put all your eggs into one basket and your advisors forgot to mention that you can't do a thesis if someone else is already doing it. Perhaps it'll help shift your perspective on how to approach goals, have preformed contingency plans & exit strategies, and how you shouldn't trust the advice, work, data, or conclusions of anyone unless you've personally verified its veracity. If you walk away from this with that paradigm shift then I would suggest that you've learned more in your PhD than most. Good luck, go find some smart creative people in your field and do some brainstorming and you'll be back to the grindstone in no time at all.