Skip to content

Regression in exception when downloading non existentent key in alpha 69 #901

@mscrivo

Description

@mscrivo

Describe the bug
Previously in 1.0.68 and below, this pseduocode of a test would work:

assert_raises(Aws::S3::Errors::NoSuchKey) do
  s3.get_object(bucket: 'some-bucket', key: 'some-key-that-was-deleted')
end

it would correctly raise the NoSuckKey exception, but as of 1.0.69, it now throws this exception instead:

Class: <Seahorse::Client::NetworkingError>
Message: <"http response body truncated, expected 119 bytes, received 0 bytes">
#!/usr/bin/env ruby
# frozen_string_literal: true

# Minimal reproduction script for RustyFS issue where deleting a file
# and then trying to download it returns a networking error instead of NoSuchKey
#
# Expected: Aws::S3::Errors::NoSuchKey
# Actual: Seahorse::Client::NetworkingError: http response body truncated, expected 119 bytes, received 0 bytes

require 'aws-sdk-s3'
require 'securerandom'

# Configuration - adjust these to match your RustyFS setup
S3_ENDPOINT = 'http://localhost:9000'
BUCKET_NAME = 'test-bucket'
AWS_ACCESS_KEY = 'rustfs'
AWS_SECRET_KEY = 'rustfs123'
AWS_REGION = ENV['AWS_REGION'] || 'us-west-2'

puts '=' * 80
puts 'RustyFS Bug Reproduction Script'
puts '=' * 80
puts "S3 Endpoint: #{S3_ENDPOINT}"
puts "Bucket: #{BUCKET_NAME}"
puts '=' * 80
puts

# Initialize S3 client
s3_client =
  Aws::S3::Client.new(
    endpoint: S3_ENDPOINT,
    access_key_id: AWS_ACCESS_KEY,
    secret_access_key: AWS_SECRET_KEY,
    region: AWS_REGION,
    force_path_style: true,
  )

# Create bucket if it doesn't exist
begin
  s3_client.create_bucket(bucket: BUCKET_NAME)
  puts "✓ Created bucket: #{BUCKET_NAME}"
rescue Aws::S3::Errors::BucketAlreadyOwnedByYou, Aws::S3::Errors::BucketAlreadyExists
  puts "✓ Bucket already exists: #{BUCKET_NAME}"
end

# Generate a random key and content
key = "test-file-#{SecureRandom.hex(8)}.txt"
content = 'This will be deleted soon!'

puts "\n1. Uploading file..."
puts "   Key: #{key}"
puts "   Content: #{content}"

# Upload the file
s3_client.put_object(bucket: BUCKET_NAME, key: key, body: content)
puts '   ✓ File uploaded successfully'

puts "\n2. Verifying file exists..."
# Verify the file exists
response = s3_client.get_object(bucket: BUCKET_NAME, key: key)
downloaded_content = response.body.read
puts "   ✓ File exists with content: #{downloaded_content}"

puts "\n3. Deleting file..."
# Delete the file
s3_client.delete_object(bucket: BUCKET_NAME, key: key)
puts '   ✓ Delete operation completed'

puts "\n4. Attempting to download deleted file..."
puts '   Expected: Aws::S3::Errors::NoSuchKey'
puts '   Actual:   ',
     # Try to download the deleted file - should raise NoSuchKey
     begin
       s3_client.get_object(bucket: BUCKET_NAME, key: key)
       puts '   ✗ ERROR: No exception was raised! File still exists?'
       exit 1
     rescue Aws::S3::Errors::NoSuchKey => e
       puts '   ✓ SUCCESS: Got expected NoSuchKey exception'
       puts "   Message: #{e.message}"
       exit 0
     rescue => e
       puts '   ✗ BUG REPRODUCED: Got unexpected exception'
       puts "   Exception class: #{e.class}"
       puts "   Exception message: #{e.message}"
       puts
       puts '   Full backtrace:'
       puts '   ' + e.backtrace.join("\n   ")
       exit 1
     end

Metadata

Metadata

Labels

S-confirmingStatus: Awaiting confirmation for a resolved issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions