  The sending-or-not-sending (SNS) protocol is one of the most major variants
of the twin-field (TF) quantum key distribution (QKD) protocol and has been
realized in a 511 km field fiber, the farthest field experiment to date. In
practice, however, all decoy-state methods have unavoidable source errors, and
the source errors may be non-random, which compromises the security condition
of the existing TF-QKD protocols. In this study, we present a general approach
for efficiently calculating the SNS protocol's secure key rate with source
errors, by establishing the equivalent protocols through virtual attenuation
and tagged model. This makes the first result for TF-QKD in practice where
source intensity cannot be controlled exactly. Our method can be combined with
the two-way classical communication method such as active odd-parity pairing to
further improve the key rate. The numerical results show that if the intensity
error is within a few percent, the key rate and secure distance only decrease
marginally. The key rate of the recent SNS experiment in the 511 km field fiber
is still positive using our method presented here, even if there is $\pm 9.5\%$
intensity fluctuation. This shows that the SNS protocol is robust against
source errors.
