[PR #2126] [MERGED] Validate destination bucket exists in rewriteObject operation #2119

Closed
opened 2026-03-03 13:29:52 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/2126
Author: @fsouza
Created: 1/30/2026
Status: Merged
Merged: 1/31/2026
Merged by: @fsouza

Base: mainHead: claude/fix-issue-2124-hx2Xq


📝 Commits (2)

  • c73f9c6 fix: copy to non-existent bucket should return 404
  • cf908d2 remove redundant comments from test

📊 Changes

2 files changed (+49 additions, -0 deletions)

View changed files

📝 fakestorage/object.go (+3 -0)
📝 fakestorage/object_test.go (+46 -0)

📄 Description

Summary

Add validation to the rewriteObject endpoint to ensure the destination bucket exists before attempting to copy an object. This prevents implicit bucket creation and aligns with expected GCS behavior.

Changes

  • fakestorage/object.go: Added bucket existence check in rewriteObject method that returns HTTP 404 if the destination bucket doesn't exist
  • fakestorage/object_test.go: Added TestServiceClientRewriteObjectNonExistentDestBucket test to verify that:
    • Copy operations to non-existent buckets fail with an error
    • No bucket is implicitly created during a failed copy operation
    • The bucket count remains unchanged after the failed operation

Implementation Details

The validation is performed early in the rewriteObject flow by calling s.backend.GetBucket(dstBucket) and returning a 404 status if the bucket is not found. This ensures consistent behavior with the actual Google Cloud Storage API.

https://claude.ai/code/session_01GRpAvWhUWNbc9aZYS3ZdSP

Closes #2124.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fsouza/fake-gcs-server/pull/2126 **Author:** [@fsouza](https://github.com/fsouza) **Created:** 1/30/2026 **Status:** ✅ Merged **Merged:** 1/31/2026 **Merged by:** [@fsouza](https://github.com/fsouza) **Base:** `main` ← **Head:** `claude/fix-issue-2124-hx2Xq` --- ### 📝 Commits (2) - [`c73f9c6`](https://github.com/fsouza/fake-gcs-server/commit/c73f9c6b15ec52e96f20fbeecc7d407ba4e081c2) fix: copy to non-existent bucket should return 404 - [`cf908d2`](https://github.com/fsouza/fake-gcs-server/commit/cf908d268373ebd4e3e7a027dfc7f3f31608f56e) remove redundant comments from test ### 📊 Changes **2 files changed** (+49 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `fakestorage/object.go` (+3 -0) 📝 `fakestorage/object_test.go` (+46 -0) </details> ### 📄 Description ## Summary Add validation to the `rewriteObject` endpoint to ensure the destination bucket exists before attempting to copy an object. This prevents implicit bucket creation and aligns with expected GCS behavior. ## Changes - **fakestorage/object.go**: Added bucket existence check in `rewriteObject` method that returns HTTP 404 if the destination bucket doesn't exist - **fakestorage/object_test.go**: Added `TestServiceClientRewriteObjectNonExistentDestBucket` test to verify that: - Copy operations to non-existent buckets fail with an error - No bucket is implicitly created during a failed copy operation - The bucket count remains unchanged after the failed operation ## Implementation Details The validation is performed early in the `rewriteObject` flow by calling `s.backend.GetBucket(dstBucket)` and returning a 404 status if the bucket is not found. This ensures consistent behavior with the actual Google Cloud Storage API. https://claude.ai/code/session_01GRpAvWhUWNbc9aZYS3ZdSP Closes #2124. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 13:29:52 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#2119
No description provided.