Then, back to my point, you are saying the Bible contains a lie.
There may be another explanation, though I am not going to tell you I have studied this with the intent it takes to speak confidently on it. The word translated “sinned” can also mean “done wrong”. I would suggest this goes back to my original point, applying the verse from James. He didn’t violate a command of God, therefore, the sin was that David did something he knew he should have done differently, which would correspond to sin equaling doing something you know is wrong, whether or not you violated a command of God.
I am not saying David didn’t sin. I am saying David didn’t violate a command of God in all the days of his life — except in the matter of Uriah the Hittite. My point is not that David was sinless, it was that David didn’t violate a command of God, therefore, David with his polygynous lifestyle was not violating a command of God.
Can God sin? Absolutely not! If not, then what reason do you apply to God’s law commanding a man to take on his deceased brother’s wife, even if he is already married? That is commanding polygyny. It has nothing to do with hardness of heart, it has to do with a way The Lord planned for someone to be taken care of. It was His plan. When did that plan change? I have not seen any scripture saying it has.
Not in the way you are spinning it, but yes; the bible DOES contains lies.