arc53 / arc53/DocsGPT

fix: normalize PostgreSQL URI schemes case-insensitively

Open Beginner friendly
#2,694 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
18.3k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
29

Description

## 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:pass@example.com/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:pass@example.com/db")
# currently returns POSTGRESQL://user:pass@example.com/db
# expected postgresql+psycopg://user:pass@example.com/db

normalize_pgvector_connection_string("POSTGRESQL+PSYCOPG://user:pass@example.com/db")
# currently returns the unsupported SQLAlchemy dialect URL
# expected postgresql://user:pass@example.com/db
```

## Proposed fix

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

Contributor guide

Open the contributing guide

Research direction

Start in application/core/db_uri.py with normalize_postgres_uri and normalize_pgvector_connection_string. Add regression coverage for the two mixed-case PostgreSQL examples, preserving the URI remainder and leaving unknown schemes unchanged; done means both normalizers emit the expected canonical prefixes.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, sqlalchemy
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.