fix(base): expirationTime on large FileClient.createFile#134
Open
alejandroGM0 wants to merge 1 commit into
Open
fix(base): expirationTime on large FileClient.createFile#134alejandroGM0 wants to merge 1 commit into
alejandroGM0 wants to merge 1 commit into
Conversation
The multi-append code path in FileClientImpl.createFileImpl called FileCreateRequest.of(start) without forwarding the user-provided expirationTime, silently dropping it for files larger than FILE_CREATE_MAX_SIZE. Small-file creates already branched on expirationTime; mirror that logic for the large-file path so the initial FileCreate transaction carries the requested expiration. Adds a regression test covering createFile(byte[], Instant) with content larger than FILE_CREATE_MAX_SIZE. Signed-off-by: Alejandro <26930485+alejandroGM0@users.noreply.github.com>
ec05fcc to
22cc419
Compare
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.
Problem
FileClientImpl.createFile(byte[], Instant)silently drops the user-providedexpirationTimewhenever the payload exceedsFileCreateRequest.FILE_CREATE_MAX_SIZE.In
createFileImpl, the small-file branch correctly picks betweenFileCreateRequest.of(contents)andFileCreateRequest.of(contents, expirationTime)based on whether an expiration was supplied.
The multi-append branch unconditionally calls the one-arg factory:
FileCreateRequest.of(byte[])hardcodesexpirationTime = null, andProtocolLayerClientImpl.executeFileCreateTransactiononly callsFileCreateTransaction.setExpirationTime(...)when the request's expiration is non-null.The result is that the underlying SDK transaction never receives the requested expiration,
so the created file falls back to the SDK/network default rather than the caller's value.
The
expirationTimeparameter is even validated earlier in the method("must be in the future") before being silently discarded in this branch, which makes
the bug especially misleading.
Fix
Mirror the small-file branching logic in the multi-append branch so the initial
FileCreate transaction carries the caller-supplied
expirationTimewhen present.No changes to the append path are needed — FileAppend transactions do not accept
an expiration.
Test
Adds
testCreateFileWithExpirationForSizeGreaterThanFileCreateMaxSize, which:createFile(content, expirationTime)withcontent.length == FILE_CREATE_MAX_SIZE * 2FileCreateRequesthanded toProtocolLayerClientcarries the requestedexpirationTime(
argThat(request -> expirationTime.equals(request.expirationTime())))FileAppendtransactions followAll
FileClientImplTestunit tests pass.