#17748·OpenHands

[Bug]: Cloud MCP Basic auth save rejects Unicode credentials

Author: KHG420Created Sep 28, 2026Updated Sep 28, 2026

Operating System

macOS (the failure comes from browser btoa and is not OS-specific)

Installation Method

From source (npm run make-i18n followed by Vitest)

Agent Canvas Version

Current main at fd9145958e9e93bfbad3252fce7a69493e61215a (1.24.0).

Bug Description

Saving an MCP server with Basic authentication through the Cloud settings path throws InvalidCharacterError if its username or password contains characters outside Latin-1. headersFromMcpAuth calls btoa directly on username:password; btoa accepts only byte-valued characters. Even a Latin-1 character such as ä is encoded as Latin-1 rather than UTF-8, so a server expecting UTF-8 receives the wrong credentials.

Steps to Reproduce

  1. On a source checkout, run npm ci and npm run make-i18n.
  2. Use the Cloud settings path to save an MCP server with auth: { strategy: "basic", username: "用户", password: "päss" }. The test added in this branch invokes SettingsService.saveSettings with that payload and verifies the outgoing Cloud request.
  3. Against current main, run CI=1 npx vitest run __tests__/api/settings-service.test.ts -t 'saves Unicode MCP Basic credentials' --reporter=verbose with the test applied.

Actual Behavior

The save rejects before saveCloudSettings is called: InvalidCharacterError at basicAuthHeader in src/api/settings-service/settings-service.api.ts:247.

Current main: the Cloud MCP Basic save test fails with InvalidCharacterError

The image renders the relevant lines from the actual Vitest terminal output; the full command is shown at the top.

Expected Behavior

Saving succeeds, and the Basic Authorization header contains Base64 of the UTF-8 bytes of username:password (Basic 55So5oi3OnDDpHNz8J+UkQ== for this example). ASCII credentials continue to produce the same header as before.

Acceptance Criteria

  • Unicode MCP Basic credentials do not throw when saved through the Cloud settings path.
  • The generated Basic header encodes the credentials as UTF-8 before Base64.
  • A regression test exercises the actual Cloud settings save path and checks the outgoing header.
  • The before/after test result is documented on the fixing PR.