Confucius said: “Good medicine is bitter in the mouth but helps against illness. Loyal words grate on the ear but help in conduct. Tang and Wu prospered through ministers who spoke out. Jie and Zhou perished through ministers who said yes.” (良药苦于口而利于病,忠言逆于耳而利于行) The passage is in the Family Sayings of Confucius.
In the Records of the Grand Historian, Zhang Liang uses the same saying to urge Liu Bang to listen to unwelcome advice.