You have to be very careful with diplo in this game. DP are especially sensible; it's usually a good idea to carefully check the relations of your potential DP partner, to try and catch the possibility that something like what you report could happen, and avoid it.
Bottom line, never make a DP with the enemy of your friend. Unless it is a true backstab from your friend to your DP partner, it can be claimed that it was your oversight. Not defending the design here, I know it is a little unforgiving, but trying to rationalize it (and by doing just that, you will soon discover that you play much better).