Skip to content

fix(ui): trim the username on self-hosted sign-in - #718

Merged
richard-epsilla merged 2 commits into
HarnessRouter:mainfrom
emreocell:fix/login-trim-username
Nov 19, 2026
Merged

richard-epsilla merged 2 commits into
HarnessRouter:mainfrom
emreocell:fix/login-trim-username

Conversation

@emreocell

Copy link
Copy Markdown
Contributor

The bug

On the self-hosted sign-in, a username typed or pasted with a leading or trailing space (alice) and the correct password is rejected with "Incorrect username or password." The form accepts the input: it checks username.trim() for an empty field, but then posts the raw username. The login route compares the value as received, with an exact comparison.

Expected behavior

Surrounding whitespace in the username is ignored, the way the form's own empty-field check already treats it, so alice signs in as alice.

The fix

  • SelfHostLogin.tsx: post username.trim().
  • api/selfhost/login/route.ts: trim the username before credentialsValid, so any other client gets the same behavior. The password is never trimmed (it may legitimately start or end with a space).

This also matches profile/route.ts, which already trims the username when it stores new credentials.

Verification

From ui/ (Node 24, Windows):

  • New test in SelfHostLogin.test.tsx: typing admin posts {"username":"admin","password":" right "}.
  • New src/app/api/selfhost/login/route.test.ts (credentials from HR_AUTH_USER/HR_AUTH_PASSWORD): alice, alice and a tab/newline-wrapped alice all sign in (200 + session cookie); a wrong password and a password with added spaces still return 401.
  • Without the fix, 3 of these 11 tests fail; with it all 11 pass (npx jest src/components/SelfHostLogin.test.tsx src/app/api/selfhost/login/route.test.ts).
  • npx tsc --noEmit: clean.
  • Full npx jest: 151 suites pass, 3 fail (hrui/start/open.test.ts, hrui/setup/agent-chat-css.test.ts, hrui/memories/tree/MemoryTree.test.tsx, 7 tests); the same 3 suites with the same 7 failing tests fail on an untouched main checkout here, so they are unrelated.
  • Not run: npm run build, the gateway tests, and the container-level self-hosted flow (no Docker here).

Fixes #717

Copilot AI balanced review requested due to automatic review settings November 19, 2026 01:30
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
unified-harness-protocol Ready Ready Preview Nov 19, 2026 7:46am UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

emreocell and others added 2 commits November 18, 2026 23:46
The sign-in form checked username.trim() for emptiness but posted the raw value, and the login route compared it as typed, so a username with a stray leading or trailing space was rejected even though the form accepted it.

Trim it in the form before sending, and in the route before comparing. The password is left untouched.

Signed-off-by: Emre Öcel <73295089+emreocell@users.noreply.github.com>
… credentials still fail

The route tests from #719, which fixed #717 in the same way as #718 at the same time. The fix itself and
the form test were already in #718, so this commit carries the tests #718 doesn't have: the session
cookie a padded username gets is valid and Secure, and a wrong password, another user or a blank
username still get 401. Cherry-picked from #719 (9f725fc) unchanged, as route.session.test.ts.
@richard-epsilla

Copy link
Copy Markdown
Collaborator

Thank you @emreocell, and @FFXFF1 for #719. You both found and fixed #717 the same way, 20 seconds apart, so we're landing the two as one PR. That way the fix goes in once and both of you are credited as authors on main.

This PR now has two commits:

It will land with Rebase and merge, so each commit stays under its own author and you both count as contributors. All 17 sign-in tests pass.

@richard-epsilla richard-epsilla left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two authors, one fix: @emreocell's fix and tests, and @FFXFF1's session tests from #719. Sign-in tests 17/17; all checks green.

@richard-epsilla
richard-epsilla merged commit c9d101a into HarnessRouter:main Nov 19, 2026
12 checks passed

This branch was successfully deployed

1 active deployment
Preview — 23a653bd Deployed Nov 19, 2026 by vercel[bot]
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.

A username typed with surrounding spaces fails to sign in

4 participants