I'm attaching a script that shows an error. And a project, but you can use another if you want.
The bug occurs when an event has a non-OFX effect on it. Yes, those are a little harder to find now, but when it does happen, if a script invokes the 'IsOFX' primitive on that effect it throws an exception. "IsOFX" is implemented as a magic "get => " and does something improper behind the scenes. On the other hand, finding the same effect in the 'vegas.PlugIns' list of effects and using that 'IsOFX' does not fail.
Instructions: put the script in your folder and open a project, or my project. Select a video event that has a non-OFX effect. My project has one event with 3 effects, one of them is non-OFX.
Then run the script. On my 21.314 system it logs its perusal of event effects and traps an exception when it tries to access the event's non-OFX effect's primitive 'IsOFX'. A dialog shows the exception, and exiting the dialog shows the sequence of traversing the effects up to the point of failure.
My project:
https://drive.google.com/file/d/1gNmYXUemcM0Mk3_W6sTOnpF5-jwXCoiU/view?usp=drive_link
My script:
using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;
class EntryPoint
{
    private Vegas veg;
    private LogFile log;
    public void FromVegas(Vegas vegas)
    {
        veg = vegas;
        foreach (Track track in veg.Project.Tracks) {
            if (track.MediaType == MediaType.Video) {
                foreach (VideoEvent ve in track.Events) {
                    if (ve.Selected)
                        foreach (Effect ef in ve.Effects) {
                            if (log == null)
                                log = new LogFile();
                            log.AddLogEntry("Effect name: " + ef.PlugIn.Name);
                            PlugInNode pn = vegas.PlugIns.FindChildByName(ef.PlugIn.Name);
                            if (pn != null) {
                                log.AddLogEntry("..Found it in the vegas plugin list");
                                try {
                                    log.AddLogEntry("....Trying 'IsOFX' from the plugin list");
                                    if (pn.IsOFX)
                                        log.AddLogEntry("....successful: it is OFX");
                                    else
                                        log.AddLogEntry("....successful: it is not OFX");                                }
                                catch (Exception ex) {
                                    veg.ShowError("Caught trying 'pn.IsOFX' for '" + ef.PlugIn.Name + "' in the Vegas.PlugIns list:\r\n" + ex.Message);
                                    log.ShowLogAsDialog("after exception");
                                    throw;
                                }
                            }
                            try {
                                log.AddLogEntry("..Now trying 'IsOFX' as an effect plugin");
                                if (ef.IsOFX)
                                    log.AddLogEntry("....successful: it is OFX");
                                else
                                    log.AddLogEntry("....successful: it is not OFX");                            }
                            catch (Exception ex) {
                                veg.ShowError("Caught exception trying 'ef.IsOFX' for '" + ef.PlugIn.Name + "' as an effect plugin:\r\n" + ex.Message);
                                log.AddLogEntry("Exception: " + ex);
                                log.ShowLogAsDialog("after exception");
                                throw;
                            }
                        }
                }
            }
        }
        if (log == null)
            veg.ShowError("Select a video event with effects");
        else
            log.ShowLogAsDialog("Complete");
    }
}
I encountered this in a larger context of a custom command that surveys stuff. I tried hard to find a test case for non-OFX, and sure enough it failed.
P.S. when I view this as a post, it appears there is a missing '}'. But when I go to edit it, the '}' is there. It's the end of the first 'try' block before the 'catch'. Watch out for that.
PPS: Oh it is there, it's just scrolled way to the right. Watch out for it anyway.