Skip to content

fix(connections): don't throw on a % that isn't an escape in a pasted connection string - #1391

Merged
debba merged 1 commit into
TabularisDB:mainfrom
Xnadir:fix/connection-string-percent
Nov 5, 2026
Merged

debba merged 1 commit into
TabularisDB:mainfrom
Xnadir:fix/connection-string-percent

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

parseConnectionString decodes the username, password and database name with decodeURIComponent, which throws URIError: URI malformed on a % that doesn't start a valid escape. These all threw instead of returning a result:

postgres://user:pa%ss@localhost:5432/db     # a raw password pasted as is
postgres://us%er:pw@localhost/db
postgres://user:pw@localhost/50%off
sqlite:///tmp/50%.db

NewConnectionModal calls the parser without a try, so pasting one of these into the connection-string field threw out of the handler. Nothing was filled in, and no error was shown.

The WHATWG URL parser passes such a part through unchanged. A small decodeUriPart helper now keeps that text as typed when it isn't valid percent-encoding, and decodes it otherwise, so p%40ss is still p@ss and my%20db is still my db. It replaces the six decodeURIComponent calls in the file (network URLs, passthrough display URLs and local file paths).

Testing

  • tests/utils/connectionStringParser.test.ts (3 new tests): a password, username and database with a bare % are kept as typed; valid escapes are still decoded; a SQLite path with % works.
  • pnpm typecheck ✅, ESLint (no warnings) and Prettier on the changed files ✅.
  • Full vitest run: 497 of 498 files and 8071 tests pass. The one failure is tests/routing.test.ts, which timed out starting its local server under full-suite load on Windows. It passes 16/16 on its own and isn't touched here.

AI assistance: found and written with Claude Code, tested as above.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… connection string

parseConnectionString decoded the username, password and database with
decodeURIComponent, which throws URIError on a % that doesn't start a
valid escape. Pasting postgres://user:pa%ss@host/db (a raw password, as
people often paste them), a database named 50%off or sqlite:///tmp/50%.db
threw out of the New Connection dialog's handler, so nothing was filled
in and no error was shown.

The URL parser passes such a part through unchanged, so a lenient
decodeUriPart now keeps the text as typed when it isn't valid
percent-encoding. Valid escapes (p%40ss, my%20db) are decoded as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 09:23

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 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.

* protocol of a group, the other members become aliases for the same
* driver (e.g. `postgresql://` works wherever `postgres://` does).
*/
/**

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.

SUGGESTION: New helper was inserted between the PROTOCOL_ALIAS_GROUPS doc comment and its declaration

The existing JSDoc at lines 53-57 ("Groups of interchangeable URI schemes...") described PROTOCOL_ALIAS_GROUPS, but decodeUriPart and its own JSDoc are now placed between that comment and the constant, so the alias-group documentation is orphaned. Move decodeUriPart (with its doc comment) above line 53, or below PROTOCOL_ALIAS_GROUPS, so each doc comment stays attached to its declaration.

@kilo-code-bot

kilo-code-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Merge after addressing the minor suggestion

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1

The fix is correct: decodeUriPart falls back to the raw text when decodeURIComponent throws, and valid escapes (p%40ss, my%20db) still decode. All six call sites are replaced and the new tests cover the reported inputs, valid escapes and the SQLite path case.

Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/web-ui/src/utils/connectionStringParser.ts 58 decodeUriPart and its JSDoc were inserted between the PROTOCOL_ALIAS_GROUPS doc comment and its declaration, leaving that comment orphaned. Move the helper above or below the constant.
Files Reviewed (2 files)
  • packages/web-ui/src/utils/connectionStringParser.ts - 1 issue
  • packages/web-ui/tests/utils/connectionStringParser.test.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5.5 · Input: 248 · Output: 2.4K · Cached: 239.7K

Review guidance: REVIEW.md from base branch main

@debba debba 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.

Thanks for fixing this. Keeping a bare percent sign intact while still decoding valid escapes addresses a frustrating connection form failure, and the added cases make that distinction clear.

One small follow-up: the new decodeUriPart comment now sits between the protocol alias documentation and PROTOCOL_ALIAS_GROUPS. Please move the helper above that documentation so each comment stays attached to what it describes. This is a nit, not a blocker. I'll run the e2e checks before merging.

@debba

debba commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

I tested this in the desktop app against PostgreSQL using a username, password and database name containing literal percent signs, then repeated it with %25 escapes. Both strings filled the expected values and authenticated successfully. Lint, typecheck and the full test suite passed. This is ready to merge, with the documentation placement nit left as a follow-up. Thanks!

@debba
debba merged commit e54d1a4 into TabularisDB:main Nov 5, 2026
11 checks passed
debba pushed a commit that referenced this pull request Nov 9, 2026
…1443)

Follow-up to #1391: the helper and its comment sat between the protocol
alias documentation and PROTOCOL_ALIAS_GROUPS, separating that comment
from what it describes. No behaviour change.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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