Skip to content

Conversation

@philasmar
Copy link
Contributor

DOTNET-8274

Description

Add additional validation to UploadPartRequests in Transfer Utility

Motivation and Context

Add additional validation to UploadPartRequests in Transfer Utility

Testing

Ran tests locally
Ran successful dry run

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license


filePosition += partSize;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

is there any easy way to right a unit test/integration tests which would reach the code path that throws exception? somehow mock the ConstructUploadPartRequest call to put in incorrect values and then when the response is sent and validation is reached we assert validation error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not without restructuring a lot of existing code. Most of the stuff is created within the functions and not really mockable. Let me know if you have thoughts on how to do it.

return await _s3Client.UploadPartAsync(uploadRequest, internalCts.Token)
var response = await _s3Client.UploadPartAsync(uploadRequest, internalCts.Token)
.ConfigureAwait(continueOnCapturedContext: false);

Copy link
Contributor

Choose a reason for hiding this comment

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

i think all of the validation looks good. just a general question. it looks like we do the other validation for total number of parts = expected here

if (this._uploadResponses.Count != this._totalNumberOfParts)
(right before we do complete multi part upload).

i dont think it matters to me where we do it too much. what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

also will having the logic here fail/work for unseekable streams? i think the reason the other code is in the other place is because for unseekable streams they skip validation. wondering if this code path gets executed for unseekable stream or we need to skip it for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation if (this._uploadResponses.Count != this._totalNumberOfParts) is being skipped for unseekable streams. The new validation logic we added will and should be skipped. The code path of the UploadPart function where i added the new validation is different from the unseekable stream code path.

&& _s3Client is Amazon.S3.Internal.IAmazonS3Encryption)
{
uploadPartRequest.IsLastPart = true;
uploadPartRequest.PartSize = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this going to fail validation if we are using amazonencryption client? do we need to skip it in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why the Part Size gets set to 0, but i updated our validation to match the same behavior so that we don't cause unexpected issues.

using System.Threading;
using System.Threading.Tasks;

namespace AWSSDK.UnitTests.S3.NetFramework.Custom
Copy link
Contributor

Choose a reason for hiding this comment

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

this namespace is not right. should be AWSSDK.UnitTests

Copy link
Contributor

@peterrsongg peterrsongg Oct 28, 2025

Choose a reason for hiding this comment

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

yeah ^^ also, that means the dry run might not have run these tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will rename and rerun the dry run

Copy link
Contributor

@peterrsongg peterrsongg left a comment

Choose a reason for hiding this comment

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

can you check my comments on 193 and 194?

@philasmar philasmar requested a review from peterrsongg October 28, 2025 20:27
Copy link
Contributor

@peterrsongg peterrsongg left a comment

Choose a reason for hiding this comment

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

approving, assuming new dry run passes

@philasmar
Copy link
Contributor Author

approving, assuming new dry run passes

New dry run passed

@philasmar philasmar merged commit 2b20531 into feature/transfermanager Oct 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants