Skip to content

DB INIT error when using usernames with non-alphanumeric chars #5998

Closed
@etj

Description

CKAN version

Master 713716b (2.9.something)

Describe the bug

DB usernames with non alphanum chars will terminate in error the command ckan db init.

Steps to reproduce

Create a pg user with for instance a "@" in it, then update ckan.ini with the proper URL,
e.g.: user ckan@ckan:

sqlalchemy.url = postgresql://ckan@ckan:ckan@localhost/ckan_at

Running ckan run will not raise connection error (it won't find table, eventually).

Running ckan db init will terminate with the error:

invalid interpolation syntax in 'postgresql://ckan%40ckan:ckan@localhost/ckan_at' at position 17

Expected behavior

The command should connect to the db without errors.

Additional details

At

ckan/ckan/model/__init__.py

Lines 268 to 270 in 713716b

alembic_config.set_main_option(
"sqlalchemy.url", str(self.metadata.bind.url)
)

self.metadata.bind.url contains postgresql://ckan%40ckan:ckan@localhost/ckan_at

We could replace the line with

        alembic_config.set_main_option(
            "sqlalchemy.url", config.get("sqlalchemy.url")
        )

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions