OrchardCMS/OrchardCore · error · InvalidOperationException
The UpdateContentTask failed to evaluate the…
Error message
The UpdateContentTask failed to evaluate the 'ContentItemId'.
What it means
UpdateContentTask evaluates its ContentItemId expression via GetContentItemIdAsync; when it yields null the activity throws InvalidOperationException because it has no target content item to update. The message notes the 'ContentItemId' evaluation specifically failed.
Solutions
- Configure a valid ContentItemId expression on the UpdateContentTask.
- Verify the referenced workflow variable is set by an earlier activity.
- When triggered by content events, use the event's content item output directly.
- Add a preceding condition to ensure the value exists before this task runs.
Example fix
// before
ContentItemId: ""
// after
ContentItemId: "{{ Workflow.Input.ContentItem.ContentItemId }}" Defensive patterns
Strategy: validation
Validate before calling
var contentItemId = await GetContentItemIdAsync(workflowContext);
if (string.IsNullOrWhiteSpace(contentItemId)) throw new InvalidOperationException("UpdateContentTask: ContentItemId expression must resolve before execution."); Try / catch
try { await task.ExecuteAsync(workflowContext, activityContext); }
catch (InvalidOperationException ex) when (ex.Message.Contains("failed to evaluate the 'ContentItemId'"))
{
logger.LogWarning(ex, "UpdateContentTask skipped: ContentItemId unresolved.");
} Prevention
- Configure the ContentItemId expression on every UpdateContentTask.
- Use event output variables instead of free-text IDs.
- Validate the expression with a Log task before the update.
- Add a condition step verifying the variable is non-empty.
When it happens
Trigger: The activity's ContentItemId expression is empty, references a missing workflow variable, or the expression evaluates to null (e.g. workflow input lacks a content item).
Common situations: Workflow triggered by a non-content event; variable misspelled in the designer; preceding task that should set the variable was removed or failed.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The 'RetrieveContentTask' failed to evaluate the…
- The 'UnpublishContentTask' failed to retrieve the content…
- The 'UpdateContentTask' failed to retrieve the content item.
- The 'RetrieveContentTask' failed to retrieve the content…
- The 'UnpublishContentTask' can't unpublish the content item…
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/9c786f2607a21c8d.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs:75
}
public WorkflowExpression<string> ContentProperties
{
get => GetProperty(() =>
// new WorkflowExpression<string>(JsonConvert.SerializeObject(new { DisplayText = S["Enter a title"].Value }, Formatting.Indented)));
new WorkflowExpression<string>(JConvert.SerializeObject(new { DisplayText = S["Enter a title"].Value })));
set => SetProperty(value);
}
public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
=> Outcome(S["Done"], S["Failed"]);
public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
{
var contentItemId = (await GetContentItemIdAsync(workflowContext))
?? throw new InvalidOperationException($"The {nameof(UpdateContentTask)} failed to evaluate the 'ContentItemId'.");
var inlineEventOfSameContentItemId = string.Equals(InlineEvent.ContentItemId, contentItemId, StringComparison.OrdinalIgnoreCase);
if (inlineEventOfSameContentItemId)
{
if (InlineEvent.Name == nameof(ContentPublishedEvent))
{
throw new InvalidOperationException($"The '{nameof(UpdateContentTask)}' can't update the content item as it is executed inline from a '{nameof(ContentPublishedEvent)}' of the same content item, please use an event that is triggered earlier.");
}
if (InlineEvent.Name == nameof(ContentDraftSavedEvent))
{
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.");
}
}
ContentItem contentItem = null;
View on GitHub (pinned to 4306c0717f)