luckyframework / luckyframework/avram

Better error for createdb

Open
#630 0 comments 0 reactions 0 assignees View on GitHub
improve error experience
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

We saw an issue in the Discord chat where someone was working locally, but using a remote DB on digitalocean. When running the `db.create` task, it was failing with this error:

```
createdb: error: could not connect to database template1: FATAL: pg_hba.conf rejects connection for host "XXX.XXX.XXX.XXX", user "doadmin", database "template1", SSL on
FATAL: no pg_hba.conf entry for host "XXX.XXX.XXX.XXX", user "doadmin", database "template1", SSL off
```

The confusing thing (if you're not familiar with postgres) is that it mentions "template1", but that wasn't the name of the database. This specific issue was most likely the cause of DigitalOcean blocking the IP ([ref](https://www.digitalocean.com/community/questions/can-t-create-database)).

I think if we run a task, and it mentions "template1", we can do better about the error message. Maybe print out the actual postgres command we ran, and possibly give some suggestions as to what it *might* be.

Contributor guide

Open the contributing guide

Research direction

Start with the `db.create` task and reproduce the failure against a remote PostgreSQL database that rejects the connection. Trace how the `template1` error is surfaced and determine what command or connection context is available. Done means the error explains the actual command or relevant cause and provides useful guidance instead of only the confusing `template1` message.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.