{"record":{"id":"3b5b27cd3aa7d181","repo":"OrchardCMS/OrchardCore","slug":"the-updatecontenttask-failed-to-retrieve-the-content-item","errorCode":null,"errorMessage":"The 'UpdateContentTask' failed to retrieve the content item.","messagePattern":"The 'UpdateContentTask' failed to retrieve the content item\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs","lineNumber":105,"sourceCode":"            {\n                throw new InvalidOperationException($\"The '{nameof(UpdateContentTask)}' can't update the content item as it is executed inline from a '{nameof(ContentDraftSavedEvent)}' of the same content item, please use an event that is triggered earlier.\");\n            }\n        }\n\n        ContentItem contentItem = null;\n\n        if (!inlineEventOfSameContentItemId)\n        {\n            contentItem = await ContentManager.GetAsync(contentItemId, VersionOptions.DraftRequired);\n        }\n        else\n        {\n            contentItem = workflowContext.Input.GetValue<IContent>(ContentEventConstants.ContentItemInputKey)?.ContentItem;\n        }\n\n        if (contentItem == null)\n        {\n            throw new InvalidOperationException($\"The '{nameof(UpdateContentTask)}' failed to retrieve the content item.\");\n        }\n\n        if (!inlineEventOfSameContentItemId && InlineEvent.IsStart && InlineEvent.ContentType == contentItem.ContentType)\n        {\n            if (InlineEvent.Name == nameof(ContentUpdatedEvent))\n            {\n                throw new InvalidOperationException($\"The '{nameof(UpdateContentTask)}' can't update the content item as it is executed inline from a starting '{nameof(ContentUpdatedEvent)}' of the same content type, which would result in an infinitive loop.\");\n            }\n\n            if (Publish && InlineEvent.Name == nameof(ContentPublishedEvent))\n            {\n                throw new InvalidOperationException($\"The '{nameof(UpdateContentTask)}' can't publish the content item as it is executed inline from a starting '{nameof(ContentPublishedEvent)}' of the same content type, which would result in an infinitive loop.\");\n            }\n\n            if (!Publish && InlineEvent.Name == nameof(ContentDraftSavedEvent))\n            {\n                throw new InvalidOperationException($\"The '{nameof(UpdateContentTask)}' can't update the content item as it is executed inline from a starting '{nameof(ContentDraftSavedEvent)}' of the same content type, which would result in an infinitive loop.\");\n            }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs#L87-L123","documentation":"UpdateContentTask could not resolve any content item to update: the evaluated ID path yielded nothing and the workflow input contained no IContent under ContentEventConstants.ContentItemInputKey. The activity throws rather than silently doing nothing.","triggerScenarios":"contentItem remains null after all resolution attempts — no valid ContentItemId expression result and no content item present in the workflow input (e.g. workflow started by a non-content trigger).","commonSituations":"Timer/HTTP-triggered workflows with no content item context; a custom trigger that doesn't set the standard ContentItemInputKey input.","solutions":["Provide a valid ContentItemId expression on the activity so the item resolves by ID.","Start the workflow from a content event that injects the content item input, or manually add the input under ContentEventConstants.ContentItemInputKey.","Add a preceding task that loads the content item into workflow context.","Log the workflow input before this task to confirm what is available."],"exampleFix":"// before\nworkflowContext.Input lacks ContentItemInputKey; task has no ContentItemId\n// after\nContentItemId: \"{{ Workflow.Input.ContentItem.ContentItemId }}\" or pass IContent input keyed ContentEventConstants.ContentItemInputKey","handlingStrategy":"validation","validationCode":"var input = workflowContext.Input.GetValue<IContent>(ContentEventConstants.ContentItemInputKey);\nif (input?.ContentItem is null && string.IsNullOrWhiteSpace(configuredContentItemId))\n    throw new InvalidOperationException(\"UpdateContentTask: no content item input and no ContentItemId expression.\");","typeGuard":null,"tryCatchPattern":"try { await task.ExecuteAsync(workflowContext, activityContext); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"failed to retrieve the content item\"))\n{\n    logger.LogWarning(ex, \"UpdateContentTask aborted: no content item could be resolved.\");\n}","preventionTips":["Ensure triggering events supply the standard ContentItem input key.","For non-content triggers, always configure a ContentItemId expression.","Set the input via ContentEventConstants.ContentItemInputKey in custom triggers.","Log workflow inputs in development to catch missing context early."],"tags":["workflows","content","not-found","null-value"],"backgroundTag":"entity-not-found","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}