feat(storage): add backend-agnostic conditional-copy support to CopyOptions - #1265
Open
tripodsan wants to merge 1 commit into
Open
feat(storage): add backend-agnostic conditional-copy support to CopyOptions#1265tripodsan wants to merge 1 commit into
tripodsan wants to merge 1 commit into
Conversation
…ptions Adds ifMatch/ifNoneMatch (destination) and sourceIfMatch (source) as normalized CopyOptions fields, following the same pattern as the existing metadataDirective abstraction. Previously, conditional-copy predicates could only be expressed via the untyped, backend-native copyOpts escape hatch (e.g. S3's IfMatch/IfNoneMatch/CopySourceIfMatch), which meant callers relying on optimistic-concurrency semantics for copy operations only worked against S3 and were silent no-ops against Azure. - S3Backend maps the new fields onto CopyObjectCommand's native IfMatch/IfNoneMatch/CopySourceIfMatch fields. - AzureBackend maps them onto beginCopyFromURL's conditions/ sourceConditions shape. - Both backends' copy() now normalize any thrown error's native HTTP status onto e.status (previously only the 404 case was normalized), so callers can branch on precondition failures (412/409) without knowing the backend's native error shape. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ifMatch/ifNoneMatch(destination) andsourceIfMatch(source) as normalized, backend-agnosticCopyOptionsfields, following the same pattern already established bymetadataDirective.helix-azure-api-serviceoff S3: conditional-copy predicates could previously only be expressed via the untyped, backend-nativecopyOptsescape hatch (e.g. S3'sIfMatch/IfNoneMatch/CopySourceIfMatch), so optimistic-concurrency copy logic built against that shape silently became a no-op once a caller switched toStorageAzure(Azure's SDK expects a completely differentconditions/sourceConditionsshape).S3Backend#copy()maps the new fields ontoCopyObjectCommand's nativeIfMatch/IfNoneMatch/CopySourceIfMatch.AzureBackend#copy()maps them ontobeginCopyFromURL'sconditions/sourceConditions.copy()now normalize any thrown error's native HTTP status ontoe.status(previously only the "source missing" 404 case was normalized), so callers can branch on precondition failures (412/409) without knowing the backend's native error shape.Why
helix-azure-api-service'ssource-client.jsimplements optimistic-create ("copy only if destination doesn't exist") and optimistic-update/versioning ("copy only if destination/source etag still matches") on top ofBucket#copy(), using raw AWS-SDK-v3 field names passed throughcopyOpts. This worked against the old S3-only backend, but is inert againstStorageAzure. Rather than teaching application code about each backend's native option shape, this extends the storage abstraction itself — the same waymetadataDirective: 'COPY'|'REPLACE'already abstracts over S3'sMetadataDirectivevs. Azure's separatesetHTTPHeaders()call.Test plan
npm testinhelix-shared-storage,helix-shared-storage-s3,helix-shared-storage-azure— all at 100% coverage (existing threshold), new tests added for: destinationifMatch/ifNoneMatchmapping, sourcesourceIfMatchmapping, and non-404 error-status normalization, for both backends.npm test --workspacesfrom the repo root — all packages pass, no regressions.npm run lintin each touched package — clean.Follow-up (separate, out of scope here): once this is released,
helix-azure-api-service'ssource-client.jswill be updated to use the new normalized fields instead of its current rawcopyOptspassthrough, and its currently-skipped copy-semantics tests will be un-skipped against real Azure behavior.🤖 Generated with Claude Code