Job Task Queue Error "Check-out and check-in operations in scripts must occur in matching pairs"

Hey everyone,

we recently encountered a strange error in one of our vault apps that suddenly appeared in the Task Queue Job. The error message itself is clear - if you check-out an object you need to check it back in again in your code. The thing is we don't do any check-out or check-in operations. All we do is delete certain objects based on a condition. When debugging the app the whole code is running without any exceptions. The error is thrown once "job.commit" is called, so my guess is that the error occurs after our code somewhere in the task process.

The app was running without any errors until a couple of weeks ago and there were supposedly no changes done to the vault.

Does anyone a similar issue or an idea what the cause could be? I am grateful for any tips Smiley From our side there are no other scripts/apps running that perform check-out/check-in operations at the same time...

Task Processor:

        [TaskProcessor(QueueId, ExcelImportCloudImportObjectDeletion, TransactionMode = TransactionMode.Hybrid)]
        [ShowOnDashboard(ExcelImportCloudImportObjectDeletion, ShowRunCommand = true)]
        public void RunDeleteObjectProcess(ITaskProcessingJob<TaskDirective> job)
        {
            job.Commit((transactionalVault) =>
            {
                if (this.Configuration?.DeleteConfiguration == null)
                {
                    if (job != null)
                        job.Update(null, "Deletion configuration is not set.");
                    return;
                }

                if (this.Configuration?.DeleteConfiguration.DeleteImportObjects != true)
                {
                    if (job != null)
                        job.Update(null, "Active is false.");
                    return;
                }

                if (this.Configuration.DeleteConfiguration.DeleteAfterDays <= 0)
                {
                    if (job != null)
                        job.Update(null, "DeleteAfterDays is less than or equal to 0.");
                    return;
                }

                DeleteImportObjects(job, transactionalVault);
            });
        }

Delete Method:

private void DeleteImportObjects(ITaskProcessingJob<TaskDirective> job, Vault vault)
{
    if (this.Configuration?.ObjectTypeToImport == null || this.Configuration?.ObjectTypeToImport.Count == 0)
    {
        if (job != null)
            job.Update(null, "No Import Objects configured!");
        return;
    }

    Logging(LogLevel.Debug, GetLogMessage($"Deletion of import objects started!"));

    int deleteCounter = 0;
    double daysToDeleteInterval = this.Configuration.DeleteConfiguration.DeleteAfterDays;
    foreach (ObjecttypeToImport objecttypeToImport in this.Configuration.ObjectTypeToImport)
    {
        try
        {
            if (!objecttypeToImport.DeleteAutomatically)
            {
                continue;
            }

            MFSearchBuilder mFSearchBuilder = new MFSearchBuilder(vault);
            mFSearchBuilder.Deleted(false);
            mFSearchBuilder.Class(objecttypeToImport.ImportClass.ID);
            mFSearchBuilder.Property(objecttypeToImport.ImportedPropDef, true);

            List<ObjVerEx> results = mFSearchBuilder.FindEx();
            Logging(LogLevel.Debug, GetLogMessage($"Objects to delete found: {results.Count}; Checking 'last modified' date..."));
            foreach (ObjVerEx objVerEx in results)
            {
                if (objVerEx.TryGetProperty(MFBuiltInPropertyDef.MFBuiltInPropertyDefLastModified, out PropertyValue propVal))
                {
                    DateTime lastModified = propVal.TypedValue.GetValueAsTimestamp().ToDateTime();
                    DateTime currentDate = DateTime.Now;

                    if ((currentDate - lastModified).TotalDays <= daysToDeleteInterval)
                        continue;

                    if (objecttypeToImport.DestroyObject)
                    {
                        vault.ObjectOperations.DestroyObject(objVerEx.ObjID, true, -1);
                    }
                    else
                    {
                        vault.ObjectOperations.DeleteObject(objVerEx.ObjID);
                    }
                    deleteCounter++;
                }
            }
        }
        catch (Exception ex)
        {
            Logging(LogLevel.Error, GetLogMessage($"{ex.Message}"));
        }
    }
    job.Update(100, "Deleted " + deleteCounter + " objects.");
    Logging(LogLevel.Debug, GetLogMessage($"Deletion of {deleteCounter} objects succeded!"));
}