#2694·DocsGPT

fix: normalize PostgreSQL URI schemes case-insensitively

Author: yaodong-shenCreated Aug 23, 2026Updated Aug 23, 2026

Bug description

application/core/db_uri.py recognizes PostgreSQL URI prefixes with case-sensitive startswith() checks. URI schemes are case-insensitive, so a valid operator-supplied value such as POSTGRESQL://user:[email protected]/db is returned unchanged. SQLAlchemy then fails with NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:POSTGRESQL. Likewise, POSTGRESQL+PSYCOPG://... is not converted to the libpq-compatible form for PGVECTOR_CONNECTION_STRING.

Expected behavior

Recognized PostgreSQL schemes should be normalized regardless of their casing, while preserving the remainder of the URI and leaving unknown schemes unchanged.

Reproduction

python
normalize_postgres_uri("POSTGRESQL://user:[email protected]/db")
# currently returns POSTGRESQL://user:[email protected]/db
# expected postgresql+psycopg://user:[email protected]/db

normalize_pgvector_connection_string("POSTGRESQL+PSYCOPG://user:[email protected]/db")
# currently returns the unsupported SQLAlchemy dialect URL
# expected postgresql://user:[email protected]/db

Proposed fix

Match only the recognized scheme prefix case-insensitively, emit the canonical lowercase target prefix, and add regression coverage for both normalizers.