fix: use UTF-8 encoding for BBS Basic Auth to support special-char passwords#1588
Open
vamsicherukuri wants to merge 1 commit into
Open
fix: use UTF-8 encoding for BBS Basic Auth to support special-char passwords#1588vamsicherukuri wants to merge 1 commit into
vamsicherukuri wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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 embedded1 |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}")); |
Unit Test Results 1 files 1 suites 27s ⏱️ 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>
8144d28 to
21933fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BbsClientwas usingEncoding.ASCIIto encode Basic Auth credentials before Base64 encoding. Any character outside ASCII (0–127) was silently corrupted to?, causing a401 Unauthorizedresponse from Bitbucket Server when the password contained special characters.Encoding.UTF8per RFC 7617 (The 'Basic' HTTP Authentication Scheme).€,ñ,@,$, etc.).Fixes #1587
Checklist
ThirdPartyNotices.txt(if applicable)Test plan
dotnet test— all existingBbsClientTestspass with the updated UTF-8 expectationIt_Adds_The_Authorization_Header_When_Password_Contains_Special_Characterspassesbbs2gh migrate-repoagainst a Bitbucket Server instance with a password containing non-ASCII characters and confirm no 401 error🤖 Generated with Claude Code