I understand your reasoning and that of others;
but I do not accept it because of what it points to. Now it is not only Paul and Peter who were in error, but it is God Himself who tolerates error for the greater good.
In other words, the end justifies the means.
I think you have an unusual concept of God not allowing for man's ability to make mistakes. After all, God created Adam. Yet? Why did God allow Adam to be created if he knew he would fall?
I think the problem here, is that you have a concept of the Apostles that romanticizes them in an unrealistic way.
Well? If what you say were true? Why would God choose Peter? Knowing the following would take place?
Galatians 2:11-13 (New International Version)
"When Peter came to Antioch, I opposed him to his face, because he was clearly in the wrong. Before certain men came from James, he used to eat with the Gentiles. But when they arrived, he began to draw back and separate himself from the Gentiles because he was afraid of those who belonged to the circumcision group. The other Jews joined him in his hypocrisy, so that by their hypocrisy even Barnabas was led astray."
God
must tolerate error with those he has chosen! For we are all remaining capable of error at any given moment. If God is not to allow for error? Then God might as well hang his mercy up on a rack and not have it be a part of his nature.
I was very easy for both Paul and Peter to be wrong at times, especially in the early days of the Church. For the Church was to the OT dispensation, as the car was to the horse. It was a new means in salvation and there had to be a learning curve issue, which means some errors would be made and then corrected.
God would not have chosen Paul and Peter if God knew they would refuse correction. That is what made both Peter and Paul perfect. They were correctable.

After correction they were ready to be used to write Scripture!
Are you correctable? I am. Been corrected many times.
It scared me to see how wrong I was, yet so sure of myself when I was.
Yet, I also knew believers who refused correction. They can not grow spiritually as long as they do. Religion would be perfect for them. It requires no growth. Only obedience to a predetermined unchanging format. Heaven forbid if it is shown it needs to be corrected. Might as well tell God he needs to be corrected. That how some religious people I know think about what they follow. Might as well be God.
The Church is not God. Look at some of the errors your church has made in the past? I have seen errors in mine. The only way we can grow is to learn truth that we did not know before. That, in some cases, will include correction.
The church is not omniscient. It does not know all it can know. A Church is a living organism if its growing in grace and truth. Religion is a like a prison wall that gives some folks a sense of security they crave. Predictablity. Life is not like that. Paul and Peter were growing and sometimes making mistakes that they needed to correct along the way. I see no problem with that. You do? Why?
Galatians 2:11-13 (New International Version)
"When Peter came to Antioch, I opposed him to his face, because he was clearly in the wrong. Before certain men came from James, he used to eat with the Gentiles. But when they arrived, he began to draw back and separate himself from the Gentiles because he was afraid of those who belonged to the circumcision group. The other Jews joined him in his hypocrisy, so that by their hypocrisy even Barnabas was led astray."
Peter made mistakes... God did not make a mistake. You say that means God made a mistake? He always knew Peter would do that when he chose Peter as his Apostle. Grace, Mercy, and Truth overcomes all the mistakes any believer can make if he desires to know God.