fix(storage-postgres): build socket-aware connection URLs (#52)#89
Open
flightlesstux wants to merge 1 commit into
Open
fix(storage-postgres): build socket-aware connection URLs (#52)#89flightlesstux wants to merge 1 commit into
flightlesstux wants to merge 1 commit into
Conversation
`extenddb init --pg-host /var/run/postgresql` previously wrote a URL of the form `postgresql://user:pw@/var/run/postgresql:5432/db` into both `extenddb.toml` and the catalog `data_database_connection_string` row. The unencoded forward slashes in the host segment break standard URL parsing, so `sqlx::PgPool::connect` rejected the URL at daemon startup with `error with configuration: empty host`, leaving init-time success followed by serve-time failure. Switch the URL builder in `bootstrapper.rs` to a new `config::build_connection_url` helper that emits the documented PostgreSQL socket form when the host is a path: postgresql://user:pw@localhost:5432/db?host=/var/run/postgresql TCP hosts still use the classic form. Update the custom `parse_connection_string` to honor a `?host=<path>` query parameter, preserving the existing split logic for the URL host segment. Tests round-trip both URL shapes through the custom parser and through `sqlx::postgres::PgConnectOptions::from_str` so the regression is caught at the same parser layer the daemon uses.
Collaborator
|
Hi Ercan! Thanks for the PR. I'll let the reviewers weigh in on this approach vs #92 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix
extenddb init --pg-host <socket-path>producing a connection URL that the daemon's PostgreSQL driver rejects at startup witherror with configuration: empty host.Why
Closes #52
initwas writing URLs of the formpostgresql://user:pw@/var/run/postgresql:5432/dbinto bothextenddb.tomland the catalogdata_database_connection_stringrow. The unencoded forward slashes in the host segment break standard URL parsing, sosqlx::PgPool::connectrejected the URL at daemon startup. Init succeeded,servefailed, and users had to hand-edit both the TOML and the catalog row to recover.Changes
crates/storage-postgres/src/config.rs: newbuild_connection_url()helper. Whenhoststarts with/it emits the documented PostgreSQL socket formpostgresql://user:pw@localhost:5432/db?host=/var/run/postgresql. TCP hosts keep the classic form.parse_connection_string()now honors a?host=<path>query parameter with last-value-wins libpq semantics; an empty value falls back to the URL host so existing parse callers stay backwards compatible.crates/storage-postgres/src/bootstrapper.rs:app_connection_url()delegates to the new builder. No other behavior change.Testing done
Added 10 unit tests in
crates/storage-postgres/src/config.rs:?host=value.?host=falls back to the URL host.sqlx::postgres::PgConnectOptions::from_strfor both URL shapes. This is the same parser the daemon uses, so it directly verifies the fix at the failure layer.Results:
```
cargo test --workspace --lib 382/382 passed
cargo clippy -p extenddb-storage-postgres --all-targets -- -D warnings clean
cargo fmt -p extenddb-storage-postgres -- --check (on the two changed files) clean
```
Full `cargo test --workspace` (including pytest/external integration suites) was not exercised in this branch because it requires a running PostgreSQL instance and provisioned test credentials.
Checklist