{"record":{"id":"9c786f2607a21c8d","repo":"OrchardCMS/OrchardCore","slug":"the-updatecontenttask-failed-to-evaluate-the-contentitemid","errorCode":null,"errorMessage":"The UpdateContentTask failed to evaluate the 'ContentItemId'.","messagePattern":"The UpdateContentTask failed to evaluate the 'ContentItemId'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs","lineNumber":75,"sourceCode":"    }\n\n    public WorkflowExpression<string> ContentProperties\n    {\n        get => GetProperty(() =>\n            // new WorkflowExpression<string>(JsonConvert.SerializeObject(new { DisplayText = S[\"Enter a title\"].Value }, Formatting.Indented)));\n            new WorkflowExpression<string>(JConvert.SerializeObject(new { DisplayText = S[\"Enter a title\"].Value })));\n\n\n        set => SetProperty(value);\n    }\n\n    public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n        => Outcome(S[\"Done\"], S[\"Failed\"]);\n\n    public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n    {\n        var contentItemId = (await GetContentItemIdAsync(workflowContext))\n            ?? throw new InvalidOperationException($\"The {nameof(UpdateContentTask)} failed to evaluate the 'ContentItemId'.\");\n\n        var inlineEventOfSameContentItemId = string.Equals(InlineEvent.ContentItemId, contentItemId, StringComparison.OrdinalIgnoreCase);\n\n        if (inlineEventOfSameContentItemId)\n        {\n            if (InlineEvent.Name == nameof(ContentPublishedEvent))\n            {\n                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.\");\n            }\n\n            if (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 '{nameof(ContentDraftSavedEvent)}' of the same content item, please use an event that is triggered earlier.\");\n            }\n        }\n\n        ContentItem contentItem = null;\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs#L57-L93","documentation":"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.","triggerScenarios":"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).","commonSituations":"Workflow triggered by a non-content event; variable misspelled in the designer; preceding task that should set the variable was removed or 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."],"exampleFix":"// before\nContentItemId: \"\" \n// after\nContentItemId: \"{{ Workflow.Input.ContentItem.ContentItemId }}\"","handlingStrategy":"validation","validationCode":"var contentItemId = await GetContentItemIdAsync(workflowContext);\nif (string.IsNullOrWhiteSpace(contentItemId)) throw new InvalidOperationException(\"UpdateContentTask: ContentItemId expression must resolve before execution.\");","typeGuard":null,"tryCatchPattern":"try { await task.ExecuteAsync(workflowContext, activityContext); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"failed to evaluate the 'ContentItemId'\"))\n{\n    logger.LogWarning(ex, \"UpdateContentTask skipped: ContentItemId unresolved.\");\n}","preventionTips":["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."],"tags":["workflows","content","configuration","null-value"],"backgroundTag":"missing-required-argument","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"}