Fixed the bug where rejected patches caused fatal errors. Review: #55131.
Fixed tiny issues based on review feedback. Review: #55131.