Skip to content

feat: accept a Unix socket path as the MySQL/MariaDB and PostgreSQL host - #684

Merged
David-Crty merged 1 commit into
mainfrom
fix/unix-socket-host
Oct 10, 2026
Merged

David-Crty merged 1 commit into
mainfrom
fix/unix-socket-host

Conversation

@David-Crty

@David-Crty David-Crty commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

The host validation added in #511 rejects /, so a PostgreSQL server pointing at a socket directory could no longer be saved, even though its backups kept running. PostgreSQL only needed validation to accept the path, since libpq reads a host starting with / as a socket directory.

MySQL/MariaDB is the most used engine, so it gets the same support here. Its clients need --socket, and the PDO DSN needs unix_socket=. --host=localhost is passed alongside --socket because a MYSQL_HOST in the environment (or an option file) otherwise makes both clients ignore the socket and go over TCP.

Checked end to end against MySQL 8.4, MariaDB 11.8 and PostgreSQL 17, each sharing its socket with the app image through a Docker volume: connection test, database listing, restore and dump all work, including with MYSQL_HOST set.

Things worth knowing:

  • The port stays required in the form, and is ignored for a MySQL socket.
  • An agent on 1.9 or earlier would still run --host=/path for a MySQL socket server and fail to connect, so this belongs in a minor release.
  • A socket host combined with an SSH tunnel is not rejected by validation; the connection test fails instead.

Closes #682

Summary by CodeRabbit

  • New Features
    • MySQL and PostgreSQL connections now accept Unix socket paths as host values. MySQL backups, restores, connection checks, and Adminer connections support socket-based connections.
  • Bug Fixes
    • Database-specific host validation now accepts supported socket paths while rejecting invalid paths and socket hosts for unsupported database types.

The host validation added in #511 rejects `/`, so a PostgreSQL server using a
socket directory could no longer be saved, although its backups kept running.
PostgreSQL only needed validation to accept the path, since libpq reads a host
starting with `/` as a socket directory. MySQL/MariaDB clients need `--socket`
(with an explicit `--host=localhost`, or a MYSQL_HOST in the environment
switches them back to TCP) and `unix_socket=` in the PDO DSN.

Closes #682
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d604aabd-cebe-4405-b8fb-2d842a53cf2d

📥 Commits

Reviewing files that changed from the base of the PR and between c37b287 and bdcf039.


📒 Files selected for processing (9)
  • app/Enums/DatabaseType.php
  • app/Http/Controllers/Web/AdminerController.php
  • app/Http/Requests/Api/V1/SaveDatabaseServerRequest.php
  • app/Livewire/DatabaseServer/Connection/ClientServerConnectionRules.php
  • app/Rules/SafeHost.php
  • app/Services/Backup/Databases/MysqlDatabase.php
  • tests/Feature/Http/AdminerControllerTest.php
  • tests/Feature/Rules/SafeHostTest.php
  • tests/Feature/Services/Backup/Databases/MysqlDatabaseTest.php

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: ci

🧰 Additional context used
🪛 PHPMD (2.15.0)
app/Rules/SafeHost.php

[warning] 34-34: Avoid unused parameters such as '$attribute'. (undefined)

(UnusedFormalParameter)




🔇 Additional comments (9)
app/Enums/DatabaseType.php (1)

75-90: LGTM!

Also applies to: 120-124


app/Rules/SafeHost.php (1)

25-32: LGTM!

Also applies to: 40-44


app/Http/Requests/Api/V1/SaveDatabaseServerRequest.php (1)

73-73: LGTM!


app/Livewire/DatabaseServer/Connection/ClientServerConnectionRules.php (1)

5-5: LGTM!

Also applies to: 18-18


tests/Feature/Rules/SafeHostTest.php (1)

4-4: LGTM!

Also applies to: 33-48


app/Services/Backup/Databases/MysqlDatabase.php (1)

93-116: LGTM!

Also applies to: 154-157, 265-267, 277-279, 363-365, 385-387


tests/Feature/Services/Backup/Databases/MysqlDatabaseTest.php (1)

268-281: LGTM!


app/Http/Controllers/Web/AdminerController.php (1)

49-54: LGTM!


tests/Feature/Http/AdminerControllerTest.php (1)

77-94: LGTM!





📝 Walkthrough

Walkthrough

The change adds database-type-aware validation for Unix socket host paths. MySQL backup commands and PDO connections use socket settings for those hosts. Adminer receives MySQL socket hosts in its server credential.

Changes

Unix Socket Host Support

Layer / File(s) Summary
Socket host recognition and validation
app/Enums/DatabaseType.php, app/Rules/SafeHost.php, app/Http/Requests/Api/V1/SaveDatabaseServerRequest.php, app/Livewire/DatabaseServer/Connection/ClientServerConnectionRules.php, tests/Feature/Rules/SafeHostTest.php
DatabaseType identifies MySQL and PostgreSQL as supporting socket hosts. SafeHost accepts matching absolute socket paths when given a supported database type. The API and Livewire validation paths pass the database type to the rule. Tests cover accepted and rejected paths.
MySQL socket connections
app/Services/Backup/Databases/MysqlDatabase.php, tests/Feature/Services/Backup/Databases/MysqlDatabaseTest.php
MySQL dump, restore, and connection-status commands use socket arguments for socket hosts. PDO uses a Unix-socket DSN for those hosts. Tests check socket arguments for dump and restore.
Adminer socket credentials
app/Http/Controllers/Web/AdminerController.php, tests/Feature/Http/AdminerControllerTest.php
For a MySQL socket host, Adminer receives localhost:<socket path> as the server credential. A feature test checks the credential and response.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to bdcf0

This change lets Unix socket hosts be saved and used for PostgreSQL and MySQL/MariaDB connections. No merge-blocking risk was identified in the supplied changes. Agents on version 1.9 or earlier will still fail to connect to a MySQL socket host, which the author notes calls for a minor release.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: support Unix socket paths as hosts for MySQL/MariaDB and PostgreSQL.
Linked Issues check Passed Issue #682 requires PostgreSQL hosts that are absolute Unix socket paths to pass validation so the server configuration can be saved. SafeHost now accepts the socket-path pattern for `DatabaseType::…
Out of Scope Changes check Passed The MySQL/MariaDB socket support, PDO DSN handling, CLI flags, and Adminer mapping implement the same Unix-socket host capability described in the current PR intent. The related validation and feature…


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks a socket path,
Then hops where MySQL sends its call.
The dump runs by the socket way,
Adminer gets localhost.
PostgreSQL paths pass the check,
And carrots wait beside the stack.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.74359% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.11%. Comparing base (c37b287) to head (bdcf039).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/Enums/DatabaseType.php 70.00% 3 Missing ⚠️
app/Services/Backup/Databases/MysqlDatabase.php 95.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (89.74%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #684      +/-   ##
============================================
- Coverage     92.18%   92.11%   -0.07%     
- Complexity     3513     3531      +18     
============================================
  Files           300      300              
  Lines         11958    11979      +21     
============================================
+ Hits          11023    11035      +12     
- Misses          935      944       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@David-Crty
David-Crty merged commit d191e89 into main Oct 10, 2026
4 of 5 checks passed
@David-Crty
David-Crty deleted the fix/unix-socket-host branch October 10, 2026 07:55
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.

PostgreSQL - Unable to save when host is a Unix-domain socket

1 participant