nopSolutions/nopCommerce · warning · ArgumentException

No comment found with the specified id

Error message

No comment found with the specified id

What it means

Thrown by BlogController.CommentUpdate (permission: BLOG_COMMENTS_CREATE_EDIT_DELETE). It loads the blog comment by model.Id and throws ArgumentException if missing — the comment was deleted, unapproved-and-purged, or the id is invalid before an update.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/BlogController.cs:240

    }

    [HttpPost]
    [CheckPermission(StandardPermission.ContentManagement.BLOG_COMMENTS_VIEW)]
    public virtual async Task<IActionResult> Comments(BlogCommentSearchModel searchModel)
    {
        //prepare model
        var model = await _blogModelFactory.PrepareBlogCommentListModelAsync(searchModel, searchModel.BlogPostId);

        return Json(model);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.ContentManagement.BLOG_COMMENTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> CommentUpdate(BlogCommentModel model)
    {
        //try to get a blog comment with the specified id
        var comment = await _blogService.GetBlogCommentByIdAsync(model.Id)
            ?? throw new ArgumentException("No comment found with the specified id");

        var previousIsApproved = comment.IsApproved;

        //fill entity from model
        comment = model.ToEntity(comment);

        await _blogService.UpdateBlogCommentAsync(comment);

        //raise event (only if it wasn't approved before and is approved now)
        if (!previousIsApproved && comment.IsApproved)
            await _eventPublisher.PublishAsync(new BlogCommentApprovedEvent(comment));

        //activity log
        await _customerActivityService.InsertActivityAsync("EditBlogComment",
            string.Format(await _localizationService.GetResourceAsync("ActivityLog.EditBlogComment"), comment.Id), comment);

        return new NullJsonResult();
    }

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Refresh the blog comment grid and re-attempt the edit on an existing row.
  2. Have the update action return NotFound/Json error instead of throwing on a missing comment.
  3. On the client, surface 'record no longer exists' to the user instead of a 500.

Example fix

// before
var comment = await _blogService.GetBlogCommentByIdAsync(model.Id)
    ?? throw new ArgumentException("No comment found with the specified id");

// after
var comment = await _blogService.GetBlogCommentByIdAsync(model.Id);
if (comment == null)
    return NotFound($"Blog comment {model.Id} no longer exists.");
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the comment still exists before applying the update.
var comment = await _blogService.GetBlogCommentByIdAsync(model.Id);
if (comment == null) return NotFound($"Blog comment {model.Id} no longer exists.");

Type guard

static bool BlogCommentExists(BlogComment c) => c is not null;

Try / catch

try { /* CommentUpdate body */ }
catch (ArgumentException)
{
    return NotFound($"Blog comment {model.Id} no longer exists.");
}

Prevention

When it happens

Trigger: POST CommentUpdate with a model.Id that GetBlogCommentByIdAsync cannot find: another admin deleted the comment, or the grid row is stale after moderation action.

Common situations: Concurrent moderation; inline-edit a comment that was just removed; spam cleanup job purging the row mid-edit.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/944fde803f296033. Report an issue: GitHub.