{"record":{"id":"b122ee505bfc233e","repo":"elsa-workflows/elsa-core","slug":"workflow-instance-with-id-workflowinstanceid-does-not-exist","errorCode":null,"errorMessage":"Workflow instance with ID '{workflowInstanceId}' does not exist.","messagePattern":"Workflow instance with ID '(.+?)' does not exist\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Management/Stores/MemoryWorkflowInstanceStore.cs","lineNumber":166,"sourceCode":"\n    /// <inheritdoc />\n    public ValueTask<long> DeleteAsync(WorkflowInstanceFilter filter, CancellationToken cancellationToken = default)\n    {\n        var query = Filter(_store.List().AsQueryable(), filter);\n        var count = _store.DeleteMany(query, x => x.Id);\n        return ValueTask.FromResult(count);\n    }\n\n    /// <inheritdoc />\n    public async Task UpdateUpdatedTimestampAsync(string workflowInstanceId, DateTimeOffset value, CancellationToken cancellationToken = default)\n    {\n        var workflowInstance = await FindAsync(new()\n        {\n            Id = workflowInstanceId\n        }, cancellationToken);\n        \n        if (workflowInstance == null)\n            throw new InvalidOperationException($\"Workflow instance with ID '{workflowInstanceId}' does not exist.\");\n        \n        workflowInstance.UpdatedAt = value;\n    }\n\n    private static string GetId(WorkflowInstance workflowInstance) => workflowInstance.Id;\n\n    [RequiresUnreferencedCode(\"Calls Elsa.Workflows.Management.Filters.WorkflowInstanceFilter.Apply(IQueryable<WorkflowInstance>)\")]\n    private static IQueryable<WorkflowInstance> Filter(IQueryable<WorkflowInstance> query, WorkflowInstanceFilter filter) => filter.Apply(query);\n}","sourceCodeStart":148,"sourceCodeEnd":175,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Management/Stores/MemoryWorkflowInstanceStore.cs#L148-L175","documentation":"MemoryWorkflowInstanceStore.UpdateUpdatedTimestampAsync requires an existing workflow instance. When no instance with the given ID exists in the in-memory store, it throws InvalidOperationException stating the instance does not exist, rather than silently succeeding.","triggerScenarios":"Calling UpdateUpdatedTimestampAsync with a workflowInstanceId that was never added to the store, was deleted, or refers to an instance in a different store (e.g. instance persisted in the database while this call hits the memory store).","commonSituations":"Unit-test setups using the memory store against IDs from a real database; stale IDs after instance deletion; race conditions where the instance was removed concurrently.","solutions":["Verify the workflow instance exists (e.g. via FindAsync) before calling UpdateUpdatedTimestampAsync.","Ensure the same store implementation is used for reading and updating instance timestamps.","Catch InvalidOperationException and treat the update as a no-op or log the missing instance ID."],"exampleFix":"// before\nawait store.UpdateUpdatedTimestampAsync(instanceId, DateTimeOffset.UtcNow);\n// after\nvar instance = await store.FindAsync(new() { Id = instanceId });\nif (instance != null)\n    await store.UpdateUpdatedTimestampAsync(instanceId, DateTimeOffset.UtcNow);","handlingStrategy":"try-catch","validationCode":"var existing = await store.FindAsync(new() { Id = instanceId });\nif (existing == null) return; // nothing to update","typeGuard":null,"tryCatchPattern":"try { await store.UpdateUpdatedTimestampAsync(instanceId, timestamp); } catch (InvalidOperationException) { logger.LogWarning(\"Instance {Id} not found for timestamp update\", instanceId); }","preventionTips":["Verify instance existence before updating derived fields","Use the same store implementation across read/update paths","Treat missing instances as idempotent no-ops in background jobs","Log instance IDs that fail updates for diagnosis"],"tags":["persistence","workflow-instances","memory-store"],"backgroundTag":"record-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}