Skip to content

fix: use UTF-8 encoding for BBS Basic Auth to support special-char passwords#1588

Open
vamsicherukuri wants to merge 1 commit into
github:mainfrom
vamsicherukuri:fix/bbs-client-utf8-basic-auth
Open

fix: use UTF-8 encoding for BBS Basic Auth to support special-char passwords#1588
vamsicherukuri wants to merge 1 commit into
github:mainfrom
vamsicherukuri:fix/bbs-client-utf8-basic-auth

Conversation

@vamsicherukuri

Copy link
Copy Markdown

Summary

  • BbsClient was using Encoding.ASCII to encode Basic Auth credentials before Base64 encoding. Any character outside ASCII (0–127) was silently corrupted to ?, causing a 401 Unauthorized response from Bitbucket Server when the password contained special characters.
  • Fixed by switching to Encoding.UTF8 per RFC 7617 (The 'Basic' HTTP Authentication Scheme).
  • Added a new unit test covering passwords with non-ASCII special characters (, ñ, @, $, etc.).

Fixes #1587

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)

Test plan

  • Run dotnet test — all existing BbsClientTests pass with the updated UTF-8 expectation
  • New test It_Adds_The_Authorization_Header_When_Password_Contains_Special_Characters passes
  • Manual: run bbs2gh migrate-repo against a Bitbucket Server instance with a password containing non-ASCII characters and confirm no 401 error

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 12, 2026 18:39

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes Bitbucket Server Basic Auth encoding so passwords containing non-ASCII characters authenticate correctly (avoiding 401s).

Changes:

  • Switch Basic Auth credential encoding from ASCII to UTF-8 in BbsClient.
  • Add a unit test that covers passwords with special/non-ASCII characters.
  • Add a release note describing the bug fix.

Reviewed changes

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

File Description
src/Octoshift/Services/BbsClient.cs Updates Basic Auth encoding to UTF-8 to support non-ASCII passwords.
src/OctoshiftCLI.Tests/Octoshift/Services/BbsClientTests.cs Adds test coverage for special/non-ASCII characters in passwords and aligns existing test to UTF-8.
RELEASENOTES.md Documents the behavior change and the 401 fix.
Comments suppressed due to low confidence (1)

RELEASENOTES.md:1

  • This line appears to include the diff renderer artifacts (1 |) as literal file content, which will break Markdown formatting and may confuse any tooling that parses release notes. It should be a normal Markdown bullet (e.g., - Fixed ...) without the embedded 1 | prefix and with consistent indentation.
- Fixed a bug where `bbs2gh migrate-repo` would return a 401 Unauthorized error when the Bitbucket Server password contained special (non-ASCII) characters. Basic Auth credentials are now encoded with UTF-8 instead of ASCII.

if (_httpClient != null)
{
var authCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
var authCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Unit Test Results

    1 files      1 suites   27s ⏱️
1 111 tests 1 111 ✅ 0 💤 0 ❌
1 112 runs  1 112 ✅ 0 💤 0 ❌

Results for commit 21933fe.

♻️ This comment has been updated with latest results.

…sswords

Encoding.ASCII silently replaces any character outside 0-127 with '?'
before Base64 encoding, causing a corrupted Authorization header and a
401 Unauthorized response from Bitbucket Server when the password
contains non-ASCII characters.

Switch to Encoding.UTF8 per RFC 7617 recommendation.

Fixes github#1587

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vamsicherukuri vamsicherukuri force-pushed the fix/bbs-client-utf8-basic-auth branch from 8144d28 to 21933fe Compare June 12, 2026 19:05
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
gei 81% 73% 608
gl2gh 77% 70% 417
ado2gh 71% 69% 747
Octoshift 80% 70% 1974
bbs2gh 83% 78% 667
Summary 79% (8817 / 11179) 71% (2200 / 3079) 4413

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.

bbs2gh migrate-repo: 401 Unauthorized when Bitbucket Server password contains special characters

2 participants