The sensitivity of nonlinear harmonic generation to electron beam quality in free electron lasers