A regression due to
NIFI-7012 causes InvokeScriptedProcessor to initially be marked invalid if the Module Directory property is set. This is because of a copy-paste bug that sets the script body value to the module directory value, and when OnConfigurationRestored is called, the processor fails validation.
The code should correctly set the module directory variable to the value of the module directory property. A workaround is to change the Script Body property (add a newline, e.g.) and Apply the changes.