Skip to content

Fix false "Unauthorized" error when target repo name was renamed away - #1616

Merged
brianaj merged 2 commits into
mainfrom
migration-friction-5843
Oct 2, 2026
Merged

brianaj merged 2 commits into
mainfrom
migration-friction-5843

Conversation

@brianaj

@brianaj brianaj commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Migrating to a target repo name that was previously used and renamed away (leaving a redirect) fails with a misleading Unauthorized - check your token error. The token is valid and the name is free — the migration should succeed.

Cause

gl2gh and bbs2gh build their HTTP clients with AllowAutoRedirect left at its default (true). The target-exists check hits a same-host 301, .NET follows it and strips the Authorization header on the hop, and the anonymous retry returns a 401 that we rewrite into a token error. gei already sets AllowAutoRedirect = false and is unaffected.

Fix

  • Set AllowAutoRedirect = false on the gl2gh and bbs2gh HTTP handlers, matching gei. A 301 now surfaces to DoesRepoExist as "name is free" and the migration proceeds.
  • Fixed DoesRepoExist_Returns_False_When_301, which previously asserted nothing (it stubbed the wrong status and never exercised the 301 path).
  • Added a release note.

Notes

  • ado2gh has no target-exists probe, so it's unaffected and left as-is.

Testing

  • Full unit suite passes (1176).

  • 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 AI balanced review requested due to automatic review settings October 2, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Disabling redirects on shared clients also affects GitLab and Bitbucket source requests.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Fixes false authorization failures caused by repository-name redirects.

Changes:

  • Disables automatic redirects in gl2gh and bbs2gh.
  • Corrects 301 handling test coverage.
  • Adds release notes.
File Description
src/​gl2gh/​Program.cs Configures HTTP redirect handling.
src/​bbs2gh/​Program.cs Configures HTTP redirect handling.
src/​OctoshiftCLI.Tests/​Octoshift/​Services/​GithubApiTests.cs Correctly exercises the 301 path.
RELEASENOTES.md Documents the fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/bbs2gh/Program.cs Outdated
Comment thread src/gl2gh/Program.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused client configuration change matches existing gei behavior and the corrected tests validate 301 handling.

Review effort: Balanced
Findings: None

Resolved since last review (2)

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Unit Test Results

    1 files      1 suites   24s ⏱️
1 176 tests 1 176 ✅ 0 💤 0 ❌
1 177 runs  1 177 ✅ 0 💤 0 ❌

Results for commit 6200325.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
gl2gh 77% 70% 418 ✔
gei 81% 74% 688 ✔
Octoshift 81% 70% 2044 ✔
bbs2gh 83% 78% 669 ✔
ado2gh 71% 70% 749 ➖
Summary 79% (9026 / 11419) 72% (2316 / 3217) 4568 ✔

@brianaj
brianaj merged commit 9ffa848 into main Oct 2, 2026
74 of 76 checks passed
@brianaj
brianaj deleted the migration-friction-5843 branch October 2, 2026 21:15
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