Skip to content

Conversation

tspascoal
Copy link
Contributor

@tspascoal tspascoal commented Jul 30, 2025

This feature allows users to configure the multipart upload chunk size by setting the GITHUB_OWNED_STORAGE_MULTIPART_BYTES environment variable.

Configuration:

  • Set the value to the desired number of bytes for each part in a multipart upload
  • Minimum value: 5 MiB
  • Default value: 100 MiB (used when the environment variable is not set)

Use cases:

  • Environments with proxies that block or mishandle large uploads
  • Slow network connections that benefit from smaller chunk sizes
  • Corporate networks with restrictive upload policies

Checklist:

  • Did you write/update appropriate tests
  • Release notes updated (if appropriate)
  • Appropriate logging output
  • Issue linked
  • Docs updated (or issue created)
  • New package licenses are added to ThirdPartyNotices.txt (if applicable)

closes #1402

Feature Enhancements:

  • Added support for configurable multipart upload chunk size via the GITHUB_OWNED_STORAGE_MULTIPART_BYTES environment variable, with a minimum of 5 MiB and a default of 100 MiB. This improves upload reliability in constrained network environments. (RELEASENOTES.md, src/Octoshift/Services/ArchiveUploader.cs, src/Octoshift/Services/EnvironmentVariableProvider.cs) [1] [2] [3]

Code Refactoring:

  • Updated the ArchiveUploader constructor to accept an EnvironmentVariableProvider instance, enabling dynamic configuration of chunk sizes based on environment variables. (src/Octoshift/Services/ArchiveUploader.cs)

  • Modified GithubApiFactory methods (Create, CreateClientNoSsl, and Create for target GitHub API) to pass EnvironmentVariableProvider to ArchiveUploader. (src/Octoshift/Factories/GithubApiFactory.cs) [1] [2] [3]

Test Updates:

  • Added extensive unit tests in ArchiveUploaderTests to validate behavior when the environment variable is set, not set, invalid, below minimum, zero, or negative. These tests ensure the default values and warnings are correctly applied. (src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs) [1] [2]

  • Updated integration tests for BbsToGithub and GhesToGithub to include EnvironmentVariableProvider in the ArchiveUploader setup. (src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs, src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs) [1] [2]

…t variable

Allows users to set an env variable GITHUB_OWNED_STORAGE_MULTIPART_BYTES with the number of bytes (min 5 Mib) for max number of bytes senter for each part in a multipart upload.

By allowing the users to use a smaller size than the default, allows the upload to work in cases a user has a proxy that mishandles or blocks big uploads or for very slow connections.

If not defined uses the default 100 Mib value
@Copilot Copilot AI review requested due to automatic review settings July 30, 2025 18:19
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 PR adds support for configuring the multipart upload chunk size for GitHub owned storage through an environment variable. The feature allows users to override the default 100 MiB chunk size with a custom value (minimum 5 MiB) by setting the GITHUB_OWNED_STORAGE_MULTIPART_BYTES environment variable.

  • Added environment variable configuration for multipart upload chunk size with validation
  • Implemented comprehensive test coverage for various edge cases and validation scenarios
  • Updated release notes to document the new feature for users

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
RELEASENOTES.md Added user-facing documentation for the new environment variable feature
src/Octoshift/Services/ArchiveUploader.cs Implemented environment variable reading, validation, and chunk size configuration with minimum size enforcement
src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs Added comprehensive unit tests for all validation scenarios and implemented proper test cleanup
Comments suppressed due to low confidence (2)

src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs:62

  • Accessing the private field _streamSizeLimit directly in tests breaks encapsulation. Consider adding a public property or internal getter to expose this value for testing purposes.
        archiveUploader._streamSizeLimit.Should().Be(customSize);

RELEASENOTES.md:1

  • There are spelling and grammatical errors: 'a environment' should be 'an environment', 'you a proxy' should be 'you have a proxy', and 'Mib' should be 'MiB' for consistency with the code comments.
- Allow overriding the multipart upload chunk size when using GitHub owned storage. Set the value of the chunk (min 5Mib) in bytes in a environment variable called GITHUB_OWNED_STORAGE_MULTIPART_BYTES (default value 100Mib). Only set this if you a proxy that doesn't allow the default size upload or if you are on a very slow connection.

Copy link

github-actions bot commented Jul 30, 2025

Unit Test Results

  1 files    1 suites   21s ⏱️
907 tests 907 ✅ 0 💤 0 ❌
908 runs  908 ✅ 0 💤 0 ❌

Results for commit 688d690.

♻️ This comment has been updated with latest results.

@tspascoal tspascoal marked this pull request as draft July 30, 2025 18:52
ArchiveUploader no longer reads the env variable directly. This eliminates the race condition in the tests
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
gei 80% 72% 566
bbs2gh 83% 77% 648
ado2gh 83% 77% 613
Octoshift 87% 76% 1480
Summary 85% (7266 / 8574) 76% (1708 / 2248) 3307

@tspascoal tspascoal marked this pull request as ready for review August 1, 2025 11:04
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.

github owned storage large uploads may fail with a timeout
1 participant