Skip to content

Consume URI in PUT response for GitHub-owned storage for GEI #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

synthead
Copy link
Collaborator

@synthead synthead commented Jun 26, 2025

Closes https://github.ghe.com/github/octoshift/issues/10765!

This PR consumes the new JSON response from the PUT "complete" request for the multipart upload flow when uploading archives to GitHub-owned storage for GEI!

This is an example of a response from the PUT response:

{
  "guid": "363b2659-b8a3-4878-bfff-eed4bcb54d35",
  "node_id": "MA_kgDaACQzNjNiMjY1OS1iOGEzLTQ4NzgtYmZmZi1lZWQ0YmNiNTRkMzU",
  "name": "git-archive.tar.gz",
  "size": 33287,
  "uri": "gei://archive/363b2659-b8a3-4878-bfff-eed4bcb54d35",
  "created_at": "2024-11-13T12:35:45.761-08:00"
}

With the changes in this PR, the JSON body ☝️ is consumed, and the GEI URI doesn't need to be interpolated anymore:

// 3. Complete the upload
await CompleteUpload(nextUrl.ToString());
return $"gei://archive/{guid}";

Here's an example of these changes at work:

[2025-06-25 18:13:03] [INFO] Uploading archive 2025-06-25_18-10-22-74170-git_archive.tar.gz to GitHub Storage
[2025-06-25 18:13:03] [INFO] Starting archive upload into GitHub owned storage: 2025-06-25_18-10-22-74170-git_archive.tar.gz...
[2025-06-25 18:13:03] [INFO] Uploading part 1/11...
[2025-06-25 18:13:06] [INFO] Uploading part 2/11...
[2025-06-25 18:13:11] [INFO] Uploading part 3/11...
[2025-06-25 18:13:15] [INFO] Uploading part 4/11...
[2025-06-25 18:13:20] [INFO] Uploading part 5/11...
[2025-06-25 18:13:25] [INFO] Uploading part 6/11...
[2025-06-25 18:13:31] [INFO] Uploading part 7/11...
[2025-06-25 18:13:36] [INFO] Uploading part 8/11...
[2025-06-25 18:13:41] [INFO] Uploading part 9/11...
[2025-06-25 18:13:45] [INFO] Uploading part 10/11...
[2025-06-25 18:13:50] [INFO] Uploading part 11/11...
[2025-06-25 18:13:55] [INFO] Finished uploading archive
[2025-06-25 18:13:55] [INFO] Upload complete
[2025-06-25 18:13:56] [INFO] Uploading archive 2025-06-25_18-10-22-74171-metadata_archive.tar.gz to GitHub Storage
[2025-06-25 18:13:56] [INFO] Upload complete
[2025-06-25 18:13:56] [INFO] Archives uploaded to blob storage, now starting migration...
  • 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)

@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 01:21
Copy link

@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 updates the multipart upload flow to consume the JSON body returned by the final PUT "complete" request and use its uri field instead of synthesizing the GEI URI.

  • Tests now mock and assert against the full JSON response, including the uri property.
  • ArchiveUploader is refactored to parse the JSON response in CompleteUpload and return the uri instead of extracting the GUID from the query string.

Reviewed Changes

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

File Description
ArchiveUploadersTests.cs Adds JObject response mocks and updates assertions to use the returned uri.
ArchiveUploader.cs Removes manual GUID parsing, parses JSON in CompleteUpload, and returns the uri.
Comments suppressed due to low confidence (2)

src/Octoshift/Services/ArchiveUploader.cs:81

  • [nitpick] Returning the GEI URI as a string may lead to formatting issues downstream. Consider having UploadMultipart return a Uri object directly for stronger typing.
            return geiUri.ToString();

src/Octoshift/Services/ArchiveUploader.cs:136

  • Parsing and immediately using the uri field without validation may throw on unexpected responses. Consider checking for missing or invalid uri and logging a clearer error if parsing fails.
            var responseData = JObject.Parse(response);

Comment on lines +58 to +66
var completeUploadResponse = new JObject
{
["guid"] = guid,
["node_id"] = "global-relay-id",
["name"] = archiveName,
["size"] = largeContent.Length,
["uri"] = geiUri,
["created_at"] = "2025-06-23T17:13:02.818-07:00"
};
Copy link
Preview

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

The completeUploadResponse initialization is duplicated across multiple tests. Consider extracting it into a common helper or fixture to reduce repetition.

Suggested change
var completeUploadResponse = new JObject
{
["guid"] = guid,
["node_id"] = "global-relay-id",
["name"] = archiveName,
["size"] = largeContent.Length,
["uri"] = geiUri,
["created_at"] = "2025-06-23T17:13:02.818-07:00"
};
var completeUploadResponse = CreateCompleteUploadResponse(guid, archiveName, largeContent.Length, geiUri);

Copilot uses AI. Check for mistakes.

@synthead synthead requested a review from a team June 26, 2025 01:24
@synthead synthead self-assigned this Jun 26, 2025
Copy link

github-actions bot commented Jun 26, 2025

Unit Test Results

  1 files    1 suites   20s ⏱️
896 tests 896 ✅ 0 💤 0 ❌
897 runs  897 ✅ 0 💤 0 ❌

Results for commit ff927dd.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 7, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
Octoshift 87% 76% 1435
bbs2gh 82% 76% 669
gei 81% 73% 596
ado2gh 84% 78% 618
Summary 84% (7264 / 8602) 76% (1704 / 2254) 3318

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.

2 participants