Skip to content

fix: connection URL parsing, SSH key resolution, and export compatibility#902

Merged
datlechin merged 4 commits into
mainfrom
fix/connection-url-parsing
Apr 27, 2026
Merged

fix: connection URL parsing, SSH key resolution, and export compatibility#902
datlechin merged 4 commits into
mainfrom
fix/connection-url-parsing

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • Fix SSH user:password@host not split (full user:pass went into SSH username field)
  • Fix usePrivateKey=true from TablePlus URLs correctly sets Private Key auth with auto-key resolution
  • Fix SSH password not included in URL export, now round-trips correctly
  • Fix formatter missing Redis database index, MongoDB auth params, and multi-host in exported URLs
  • Add safeModeLevel parsing from TablePlus URLs
  • Case-insensitive query parameter handling
  • Private Key auth resolves keys from ~/.ssh/config and default locations (id_ed25519, id_rsa, id_ecdsa) when no explicit path set
  • Add help text hint in SSH form when key path is empty

Test plan

  • Paste postgresql+ssh://root@host:24700/postgres:pass@localhost/db?usePrivateKey=true -- SSH tab shows Private Key auth, buttons enabled
  • Paste mariadb+ssh://root:sshpass@host:22/dbuser:dbpass@localhost/db -- SSH user=root, password=sshpass (not full string in user field)
  • Paste mysql://root:pass@localhost/db?safeModeLevel=2 -- safe mode set to Read Only
  • Paste postgresql://user:pass@host/db?SSLMODE=require -- SSL mode set (case-insensitive)
  • Copy URL from Redis connection with db index 3 -- URL contains /3
  • Copy URL from MongoDB connection with authSource -- URL contains ?authSource=...
  • SSH Private Key auth with empty key path connects using ~/.ssh/config or default keys

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f67ac59f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +94 to +95
if connection.type == .redis, let redisDb = connection.redisDatabase, redisDb > 0 {
sshPathComponent = String(redisDb)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep Redis SSH DB index round-trippable

When exporting SSH Redis connections, this now writes the selected Redis DB index into the path, but ConnectionURLParser.parseSSHURL still hard-codes redisDatabase: nil and does not map that path back to ParsedConnectionURL.redisDatabase. In practice, copying a Redis-over-SSH URL with DB > 0 and re-opening/importing it reconnects to DB 0 (the connection layer falls back to 0 when redisDatabase is nil), so users can run commands against the wrong logical Redis database.

Useful? React with 👍 / 👎.

Comment on lines +206 to +207
if connection.mongoUseSrv {
params.append("mongoUseSrv=true")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse exported mongoUseSrv query flag on import

The formatter now emits mongoUseSrv=true, but the parser never handles this key (there is no mongousesrv case in ConnectionURLParser.applyQueryParam), so exported URLs silently drop the SRV intent when re-imported unless the scheme is already mongodb+srv. This makes the new export field non-functional and breaks URL round-tripping for MongoDB connections that rely on the SRV toggle.

Useful? React with 👍 / 👎.

- Extract SafeModeLevel.from(urlInteger:) helper to unify mapping
- Unify resolveIdentityFiles for main and jump host SSH auth
- Simplify jump host .privateKey case to match main pattern
- Remove unrelated Localizable.xcstrings entries
- Add SafeModeLevel invalid-value test
- Add Redis database index URL parsing test
When a URL-opened connection fails before being saved, delete the
DB and SSH passwords from keychain to prevent orphaned entries with
ephemeral UUIDs. Also adds CHANGELOG entries for URL parsing changes.
@datlechin datlechin merged commit 675c765 into main Apr 27, 2026
2 checks passed
@datlechin datlechin deleted the fix/connection-url-parsing branch April 27, 2026 08:08
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.

1 participant