Skip to content

Fix DB rotate password syntax error (#191) - #200

Merged
sehkone merged 3 commits into
mainfrom
octoaide/issue-191-2026-02-14T19-39-23
Feb 15, 2026
Merged

Fix DB rotate password syntax error (#191)#200
sehkone merged 3 commits into
mainfrom
octoaide/issue-191-2026-02-14T19-39-23

Conversation

@octoaide

@octoaide octoaide Bot commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

Closes #191
Closes #210 (added by @sehkone)

Summary

This patch fixes a SQL syntax error that occurred when running bootroot rotate db to change the database user's password. PostgreSQL does not allow parameterized queries for DDL statements like ALTER ROLE ... WITH PASSWORD and CREATE ROLE ... WITH PASSWORD; the password must be supplied as a string literal.

What I changed

  • Add quote_literal function to escape and quote SQL string literals (single quotes are doubled and the value is wrapped in single quotes).
  • Update provision_db_sync in src/db.rs to use quote_literal(db_password) for ALTER ROLE ... WITH PASSWORD and CREATE ROLE ... WITH PASSWORD instead of a parameterized $1 placeholder.
  • Add unit tests for quote_literal (and existing quote_ident) to cover escaping and complex passwords.
  • Update CHANGELOG.md to document the fix.

Why this fixes the issue

Parameterized parameters ($1) are not supported in PostgreSQL for these DDL statements, which caused the syntax error seen in #191. By injecting a properly escaped string literal, the statements are valid SQL while preventing SQL injection via proper escaping of single quotes.

Files changed (high level)

  • src/db.rs: added quote_literal, updated password DDL usage, added tests
  • CHANGELOG.md: documented the change

Notes

  • The quote_literal implementation escapes single quotes by doubling them, following PostgreSQL conventions.
  • Unit and integration tests were run locally; all tests pass.

References

Fixes the root cause and ensures DB password rotation no longer produces a syntax error.

@sehkone
sehkone force-pushed the octoaide/issue-191-2026-02-14T19-39-23 branch from 56e2378 to dea9a10 Compare February 15, 2026 11:49
- Add unit tests for SQL literal escaping and SQL builders in db.rs.
- Add ignored Docker-backed integration test for provision_db_sync
  create/update password paths.
- Add single-host DB guardrails for init, infra up, and rotate db.
- Validate DB DSN host stays local-only.
- Fail when postgres port mapping is not localhost-bound.
- Add guardrail tests and update EN/KO installation docs.

Closes #210
@sehkone
sehkone merged commit 280b8b7 into main Feb 15, 2026
8 of 9 checks passed
@sehkone
sehkone deleted the octoaide/issue-191-2026-02-14T19-39-23 branch February 15, 2026 12:28
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.

Enforce single-host guardrails for step-ca PostgreSQL DB ALTER ROLE PASSWORD Syntax Error

1 participant