Add guard to key ref resource-only marking

The original code has the same guard.