mcp-context-forge icon indicating copy to clipboard operation
mcp-context-forge copied to clipboard

fix: escape % characters in DATABASE for Alembic config

Open ESnark opened this issue 1 week ago โ€ข 0 comments

๐Ÿ› Bug-fix PR

Before opening this PR please:

  1. make lint - passes ruff, mypy, pylint
  2. make test - all unit + integration tests green
  3. make coverage - โ‰ฅ 90 %
  4. make docker docker-run-ssl or make podman podman-run-ssl
  5. Update relevant documentation.
  6. Tested with sqlite and postgres + redis.
  7. Manual regression no longer fails. Ensure the UI and /version work correctly.

๐Ÿ“Œ Summary

Bootstrap script fails if DATABASE_URL contains % characters. #1533

๐Ÿ” Reproduction Steps

  1. Set DATABASE_URL with a password containing %.
  2. Run the bootstrap script or start the application: python3 -m mcpgateway.bootstrap_db or python3 -m mcpgateway.

๐Ÿž Root Cause

Alembic's Config.set_main_option() uses Python's configparser, which interprets % as interpolation syntax and raises InterpolationSyntaxError for URL-encoded characters like %40.

๐Ÿ’ก Fix Description

Escape % to %% before passing the URL to configparser.

๐Ÿงช Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage โ‰ฅ 90 % make coverage
Manual regression no longer fails steps / screenshots

๐Ÿ“ MCP Compliance (if relevant)

  • [ ] Matches current MCP spec
  • [ ] No breaking change to MCP clients

โœ… Checklist

  • [x] Code formatted (make black isort pre-commit)
  • [x] No secrets/credentials committed

ESnark avatar Dec 02 '25 05:12 ESnark