Hi Teh,
That because during data import process, context depth equals 2.(depth: How many times the plugin is firing based on certain events)
Here is a thread to make us understand the concept.
In my original block, it's
if (context.Depth > 1)
{
return;
}
Thus checking code will be passed.
So I changed the block to:
if (context.Depth > 2)
{
tracingService.Trace("Context depth is: {0}", context.Depth);
return;
}
Now it'll work for both creating record in form and data import process, and infinite loops will still be prevented.
Existing lead record:

Data in excel:

Error during data import process:

What'more, the stage of execution should be PreValidation.

Regards,
Clofly