The flaw was that the courts allowed it.
Had the framers disallowed slavery, the Constitution would have been rejected by the states. No Constitution, no USA.
Also, the states did not grant the feds the power to eradicate slavery, thus the courts could not eliminate it.