discourse/discourse · error · RuntimeError

Attempted to delete a non-/asset S3 path (#{to_delete}). Abo

Error message

Attempted to delete a non-/asset S3 path (#{to_delete}). Aborting

What it means

Error "Attempted to delete a non-/asset S3 path (#{to_delete}). Aborting" thrown in discourse/discourse.

Source

Thrown at lib/tasks/s3.rake:164

  assets_to_delete = existing_assets.dup

  # Check that all current assets are uploaded, and remove them from the to_delete list
  asset_paths.each do |current_asset_path|
    uploaded = assets_to_delete.delete?(prefix_s3_path(current_asset_path))
    if !uploaded
      puts "A current asset does not exist on S3 (#{current_asset_path}). Aborting cleanup task."
      exit 1
    end
  end

  if assets_to_delete.size > 0
    puts "Found #{assets_to_delete.size} assets to delete..."

    assets_to_delete.each do |to_delete|
      if !to_delete.start_with?(prefix_s3_path("assets/"))
        # Sanity check, this should never happen
        raise "Attempted to delete a non-/asset S3 path (#{to_delete}). Aborting"
      end
    end

    assets_to_delete.each_slice(500) do |slice|
      message = "Deleting #{slice.size} assets...\n"
      message += slice.join("\n").indent(2)
      puts message
      helper.delete_objects(slice)
      puts "... done"
    end
  else
    puts "No stale assets found"
  end
end

View on GitHub (pinned to 1b2d7253e8)

When it happens

Trigger: Thrown at lib/tasks/s3.rake:164 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of discourse/discourse@1b2d7253e8 (2026-08-26). Data as JSON: /api/errors/0c8b5d04dfc87359. Report an issue: GitHub.