[PR #2103] [MERGED] Fix metadata headers not being preserved during upload and retrieval #2098

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

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/2103
Author: @louisnow
Created: 1/3/2026
Status: Merged
Merged: 2/14/2026
Merged by: @fsouza

Base: mainHead: fix/metadata-preservation


📝 Commits (6)

  • c8debf2 fix: preserve HTTP metadata headers when storing and retrieving objects
  • 2f214b8 fix: additional metadata preservation fixes and test coverage
  • 779d647 fix: add contentEncoding and cacheControl to ComposeObject, fix gRPC gaps
  • b325281 test: add comprehensive test coverage for metadata preservation
  • 8456a77 fix: preserve contentDisposition and contentLanguage in body-based resumable uploads
  • b6f0888 fakestorage: stop setting Content-Type twice

📊 Changes

9 files changed (+550 additions, -83 deletions)

View changed files

📝 fakestorage/object.go (+18 -4)
📝 fakestorage/object_test.go (+92 -9)
📝 fakestorage/upload.go (+93 -50)
📝 fakestorage/upload_test.go (+287 -0)
📝 internal/backend/fs.go (+3 -1)
📝 internal/backend/memory.go (+3 -1)
📝 internal/backend/storage.go (+1 -1)
📝 internal/grpc/server.go (+34 -13)
📝 internal/grpc/server_test.go (+19 -4)

📄 Description

Summary

Fixes #2102 - Object metadata like Cache-Control, Content-Disposition, Content-Language, and custom x-goog-meta-* headers were being silently dropped during uploads.

The problem was that several upload handlers weren't reading these headers from the request or passing them through to the stored object. Additionally, Cache-Control wasn't being returned in JSON API responses, the gRPC server was missing metadata fields, and ComposeObject wasn't preserving encoding/cache settings.

Changes

JSON API response fixes:

  • Add cacheControl field to objectResponse struct so it gets returned to clients
  • Add cacheControl to jsonObject struct and its JSON marshal/unmarshal methods
  • Add cacheControl to bufferedObjectsToBackendObjects conversion
  • Fix JSON tag typo in multipartMetadata struct ("ContentLanguage""contentLanguage")

Upload handler fixes:

  • Simple uploads: add Content-Disposition, Content-Language, and custom x-goog-meta-* header support
  • Signed URL uploads: add Cache-Control, Content-Disposition, Content-Language support
  • Resumable uploads: add Content-Disposition, Content-Language support
  • Form/multipart uploads: add Cache-Control, Content-Disposition, Content-Language support
  • Multipart uploads: fix contentEncoding query parameter handling

Object operation fixes:

  • Add CacheControl to patchObject and updateObject handlers
  • Preserve Cache-Control during object rewrite/copy operations
  • Add contentEncoding and cacheControl parameters to ComposeObject interface and implementations (memory + filesystem backends)

gRPC server fixes:

  • Fix GetObject to include all metadata fields
  • Fix UpdateObject to include all metadata fields
  • Fix PatchObject to include CacheControl
  • Fix ListObjects to include all metadata fields
  • Fix makeObject helper to include all metadata fields

Tests:

  • Add HTTP integration tests for simple uploads, signed uploads, and form uploads with all metadata headers
  • Add test for contentEncoding query param in multipart uploads
  • Add test for patching CacheControl on existing objects
  • Update gRPC tests to verify all metadata fields (ContentEncoding, ContentDisposition, ContentLanguage, CacheControl, Metadata)
  • Add Cache-Control and Content-Language checks to existing object writer and rewrite tests

🔄 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/2103 **Author:** [@louisnow](https://github.com/louisnow) **Created:** 1/3/2026 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@fsouza](https://github.com/fsouza) **Base:** `main` ← **Head:** `fix/metadata-preservation` --- ### 📝 Commits (6) - [`c8debf2`](https://github.com/fsouza/fake-gcs-server/commit/c8debf2583340ceb6557fbfa6d813196c3aaddb9) fix: preserve HTTP metadata headers when storing and retrieving objects - [`2f214b8`](https://github.com/fsouza/fake-gcs-server/commit/2f214b852c431bb82ba9649d41d5786c544b31f2) fix: additional metadata preservation fixes and test coverage - [`779d647`](https://github.com/fsouza/fake-gcs-server/commit/779d647b324fb0e439764dc87e694833c056d484) fix: add contentEncoding and cacheControl to ComposeObject, fix gRPC gaps - [`b325281`](https://github.com/fsouza/fake-gcs-server/commit/b32528188b30fa468ca64410b90a583d78a02b2f) test: add comprehensive test coverage for metadata preservation - [`8456a77`](https://github.com/fsouza/fake-gcs-server/commit/8456a771a6deb6a953a62ddde0830707ad191654) fix: preserve contentDisposition and contentLanguage in body-based resumable uploads - [`b6f0888`](https://github.com/fsouza/fake-gcs-server/commit/b6f0888c7c2d2ce0eedefb5c6bcede643e13b2f9) fakestorage: stop setting Content-Type twice ### 📊 Changes **9 files changed** (+550 additions, -83 deletions) <details> <summary>View changed files</summary> 📝 `fakestorage/object.go` (+18 -4) 📝 `fakestorage/object_test.go` (+92 -9) 📝 `fakestorage/upload.go` (+93 -50) 📝 `fakestorage/upload_test.go` (+287 -0) 📝 `internal/backend/fs.go` (+3 -1) 📝 `internal/backend/memory.go` (+3 -1) 📝 `internal/backend/storage.go` (+1 -1) 📝 `internal/grpc/server.go` (+34 -13) 📝 `internal/grpc/server_test.go` (+19 -4) </details> ### 📄 Description ## Summary Fixes #2102 - Object metadata like Cache-Control, Content-Disposition, Content-Language, and custom `x-goog-meta-*` headers were being silently dropped during uploads. The problem was that several upload handlers weren't reading these headers from the request or passing them through to the stored object. Additionally, Cache-Control wasn't being returned in JSON API responses, the gRPC server was missing metadata fields, and ComposeObject wasn't preserving encoding/cache settings. ## Changes **JSON API response fixes:** - Add `cacheControl` field to `objectResponse` struct so it gets returned to clients - Add `cacheControl` to `jsonObject` struct and its JSON marshal/unmarshal methods - Add `cacheControl` to `bufferedObjectsToBackendObjects` conversion - Fix JSON tag typo in `multipartMetadata` struct (`"ContentLanguage"` → `"contentLanguage"`) **Upload handler fixes:** - Simple uploads: add Content-Disposition, Content-Language, and custom `x-goog-meta-*` header support - Signed URL uploads: add Cache-Control, Content-Disposition, Content-Language support - Resumable uploads: add Content-Disposition, Content-Language support - Form/multipart uploads: add Cache-Control, Content-Disposition, Content-Language support - Multipart uploads: fix contentEncoding query parameter handling **Object operation fixes:** - Add CacheControl to patchObject and updateObject handlers - Preserve Cache-Control during object rewrite/copy operations - Add contentEncoding and cacheControl parameters to ComposeObject interface and implementations (memory + filesystem backends) **gRPC server fixes:** - Fix GetObject to include all metadata fields - Fix UpdateObject to include all metadata fields - Fix PatchObject to include CacheControl - Fix ListObjects to include all metadata fields - Fix makeObject helper to include all metadata fields **Tests:** - Add HTTP integration tests for simple uploads, signed uploads, and form uploads with all metadata headers - Add test for contentEncoding query param in multipart uploads - Add test for patching CacheControl on existing objects - Update gRPC tests to verify all metadata fields (ContentEncoding, ContentDisposition, ContentLanguage, CacheControl, Metadata) - Add Cache-Control and Content-Language checks to existing object writer and rewrite tests --- <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:46 +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#2098
No description provided.