Right. Legalism is what gets condemned virtually non-stop in the Gospels.
Also, as G.K. Chesterton notes, a heresy is often a real truth that is taken just a little too far. For instance, celibacy is a real good, but insisting that everybody be celibate is a heresy. Likewise, Christ is true man, but anybody who thought that means he must not be true God is a heretic. And vice versa. (I believe there’s a lot of discussion in this in Heretics and/or Orthodoxy.) The Pharisees were right to believe in keeping the Sabbath, but wrong to believe that the Sabbath was so important that keeping it justified letting people go hungry or be left ill if we had some way to treat them.
I think it’s very tempting to believe that if something is true, it cannot be taken too far, but the truth is that only a truth is going to be attractive enough–true enough–to be capable of being distorted and taken too far. For instance, too modernize Chesterton’s example, bodily autonomy and personal dignity are real things, but to believe that they justify abortion is heresy. Likewise, chastity is real and important, but it’s wrong to act as though people with sexual sin in their pasts are wrecked forever.