Skip to content

Fix nil pointer panic in S3 DeleteObjects error logging#11

Draft
Copilot wants to merge 12 commits into
masterfrom
copilot/update-aws-sdk-go-version
Draft

Fix nil pointer panic in S3 DeleteObjects error logging#11
Copilot wants to merge 12 commits into
masterfrom
copilot/update-aws-sdk-go-version

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 23, 2026

During AWS SDK v2 migration, types.ObjectIdentifier.VersionId changed from value to *string. Error logging in DeleteObjects unconditionally dereferenced this pointer, causing panics when deleting from non-versioned buckets.

Changes

  • pkg/storages/s3/folder.go: Added nil check before dereferencing VersionId in error log
    • Uses "none" as version string when VersionId is nil
    • Occurs when versioning disabled or objects created without version IDs
// Before (panics when VersionId is nil)
tracelog.DebugLogger.Printf("object %s version %s", *obj.Key, *obj.VersionId)

// After
versionStr := "none"
if obj.VersionId != nil {
    versionStr = *obj.VersionId
}
tracelog.DebugLogger.Printf("object %s version %s", *obj.Key, versionStr)

Resolves panic in wal-g_pg_backup_mark_impermanent_test and other delete operations on non-versioned buckets.

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] update aws-sdk-go to aws-sdk-go-v2</issue_title>
<issue_description>### What feature would you like?

during build there's a warning

go: module github.com/aws/aws-sdk-go is deprecated: aws-sdk-go is deprecated. Use aws-sdk-go-v2.

can we do that update ?

Why is this feature useful?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 23, 2026 21:05
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title [WIP] Update aws-sdk-go to aws-sdk-go-v2 Migrate from deprecated aws-sdk-go v1 to aws-sdk-go-v2 Jan 23, 2026
Copilot AI requested a review from chipitsine January 23, 2026 21:25
Copilot AI and others added 4 commits February 4, 2026 12:22
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
…dates

Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Migrate from deprecated aws-sdk-go v1 to aws-sdk-go-v2 Complete AWS SDK v1 to v2 migration - fix test failures and json/v2 import Feb 4, 2026
The issue was that when using S3-compatible services (MinIO, Ceph, etc.),
wal-g was trying to detect the AWS region by calling GetBucketLocation,
which would fail with 403 errors because these services don't support
this operation the same way AWS does.

Root cause: In storage.go, the BaseEndpoint is set on the S3 client options
AFTER the session is created. During session creation, detectAWSRegion was
checking awsCfg.BaseEndpoint which was always nil, causing it to incorrectly
attempt region detection via GetBucketLocation for MinIO endpoints.

Fix: Pass the endpoint from config directly to detectAWSRegion instead of
relying on awsCfg.BaseEndpoint. Now the function properly detects non-AWS
endpoints and uses "us-east-1" as the default region without making API calls.

This fixes the Redis AOF backup test failure where MinIO endpoint was
being used but region detection was attempting GetBucketLocation.

Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Complete AWS SDK v1 to v2 migration - fix test failures and json/v2 import Fix region detection for S3-compatible services in AWS SDK v2 migration Feb 4, 2026
The DeleteObjects method was panicking when logging errors for objects
without version IDs. This occurred because:

1. When versioning is disabled, ObjectIdentifier structs are created
   without VersionId (line 555: only Key is set)
2. Error logging code (line 463) unconditionally dereferenced VersionId
3. This caused a nil pointer panic during delete operations

Fix: Check if VersionId is nil before dereferencing it in error logs.
Use "none" as the version string when VersionId is not present.

This fixes the panic in wal-g_pg_backup_mark_impermanent_test where
delete operations on non-versioned buckets would crash.

Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot AI changed the title Fix region detection for S3-compatible services in AWS SDK v2 migration Fix nil pointer panic in S3 DeleteObjects error logging Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] update aws-sdk-go to aws-sdk-go-v2

2 participants