Skip to content

Conversation

afranken
Copy link
Member

@afranken afranken commented May 9, 2025

Description

S3 API accepts * for conditional requests on all APIs. All APIs but PutObject succeed with "*" as well.

Related Issue

Fixes #2371

Tasks

  • I have signed the CLA.
  • I have written tests and verified that they fail without my change.

@afranken afranken self-assigned this May 9, 2025
@afranken afranken requested a review from Copilot May 10, 2025 08:06
Copilot

This comment was marked as outdated.

S3 API accepts * for conditional requests on all APIs.
All APIs but PutObject succeed with "*" as well.

Fixes #2371
@afranken afranken force-pushed the 2371-conditional-writes-putobject-wildcards branch from 68b8718 to 384ddda Compare May 10, 2025 08:08
@afranken afranken requested a review from Copilot May 10, 2025 08:09
Copilot

This comment was marked as outdated.

@afranken afranken force-pushed the 2371-conditional-writes-putobject-wildcards branch from 230389e to 9f506ba Compare May 12, 2025 21:44
@afranken afranken force-pushed the 2371-conditional-writes-putobject-wildcards branch from 9f506ba to 9a1e155 Compare May 12, 2025 22:14
@afranken afranken requested a review from Copilot May 14, 2025 11:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances S3Mock’s conditional request handling by allowing both "" and """" as valid wildcard etags. In addition, tests have been refactored to use centralized file constants and bucket naming has been updated for consistency.

  • Updates conditional matching logic in ObjectService to consider both wildcards.
  • Replaces local File instantiation in tests with UPLOAD_FILE constants and improves resource usage.
  • Refines bucket name generation in S3TestBase to replace "=" with "-" for consistency.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

File Description
server/src/main/java/com/adobe/testing/s3mock/service/ObjectService.java Adjusted conditional etag matching and reordered date-based checks to support "*" wildcard requests.
integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/* Updated test files to use centralized UPLOAD_FILE constants and ensure proper resource management via .use.
integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/S3TestBase.kt Modified bucket naming logic by replacing "=" with "-" and added a helper method for directory buckets.
Comments suppressed due to low confidence (2)

server/src/main/java/com/adobe/testing/s3mock/service/ObjectService.java:374

  • [nitpick] Verify that moving the unmodified-since check to after the match condition does not introduce any unintended side effects in conditional request evaluation.
var setUnmodifiedSince = ifUnmodifiedSince != null && !ifUnmodifiedSince.isEmpty();

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/S3TestBase.kt:248

  • [nitpick] Confirm that replacing '=' with '-' in bucket names aligns with the expected S3 naming conventions and does not impact any external integrations.
.replace('=', '-')

if (setUnmodifiedSince && ifUnmodifiedSince.get(0).isBefore(lastModified)) {
throw PRECONDITION_FAILED;
}

var setMatch = match != null && !match.isEmpty();
if (setMatch) {
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding an inline comment to explain why the condition now checks for both '' and '""', which will aid future maintainers in understanding the rationale behind expanding the wildcard support.

Suggested change
if (setMatch) {
if (setMatch) {
// Check for both quoted ("*") and unquoted (*) wildcards to ensure compatibility
// with different client implementations or specifications.

Copilot uses AI. Check for mistakes.

@adobe adobe deleted a comment from Copilot AI May 14, 2025
@afranken afranken force-pushed the 2371-conditional-writes-putobject-wildcards branch from f9e04c0 to 6e91c2d Compare May 14, 2025 13:25
@afranken afranken merged commit e4ecc80 into main May 15, 2025
6 checks passed
@afranken afranken deleted the 2371-conditional-writes-putobject-wildcards branch May 15, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support S3 conditional writes for PutObject API
1 participant