This is an event recorded in Six Paramitas Collection Sutra《六度集經》about how the Buddha was keeping the precept of being truthful.