Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

db commands hand psql the user and password still percent encoded

Open Beginner friendly
#449 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in lib/hanami/cli/commands/app/db/utils/postgres.rb at cli_env_vars, then reproduce with the DATABASE_URL and bundle exec hanami db create command from the issue. Done means PGUSER and PGPASSWORD contain decoded credentials and the database commands authenticate successfully.

Written by the indexing model from the issue text.

Description

bug

Describe the bug

Utils::Postgres#cli_env_vars copies URI#user and URI#password into PGUSER and PGPASSWORD as they stand. Ruby's URI leaves them percent encoded, so a user or password that holds @, :, /, #, %, + or a space reaches psql, createdb, dropdb and pg_dump in its encoded form, and Postgres refuses the login.

Sequel decodes the same URL, so the app itself connects. Only the hanami db commands fail.

https://github.com/hanami/hanami-cli/blob/v3.0.0/lib/hanami/cli/commands/app/db/utils/postgres.rb#L89-L94

To Reproduce

  1. Create a Postgres role whose password is p@ss:w/0rd.
  2. Set DATABASE_URL=postgres://app:p%40ss%3Aw%2F0rd@localhost/app_development.
  3. Run bundle exec hanami db create.

The existence check fails with password authentication failed for user "app", because psql sent p%40ss%3Aw%2F0rd.

The URL parses as follows:

require "uri"

uri = URI("postgres://app:p%40ss%3Aw%2F0rd@localhost/app_development")
uri.password                              # => "p%40ss%3Aw%2F0rd"
URI.decode_uri_component(uri.password)    # => "p@ss:w/0rd"

Expected behavior

PGUSER and PGPASSWORD hold the decoded values, the same ones Sequel logs in with. Running the user and password through URI.decode_uri_component in cli_env_vars would do it.

My environment

  • Ruby version: 4.0.6
  • hanami-cli: 3.0.0
  • Sequel: 5.108.0
  • OS: macOS 27
Dominant language
Ruby
Stars
33
Forks
55
Avg merge
4d 7h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hanami/hanami-cli

All issues in hanami/hanami-cli

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.