Installation fails to parse UInt correctly during PostgreSQL database setup #4

Closed
opened 8 months ago by nwesterhausen · 3 comments

When trying to add a postgres database connection, receive an int parsing error. Repeatable with the default values.

Error created:

2021/05/19 13:59:42 /root/src/mvoCI/core/models.go:217
[error] failed to initialize database, got error cannot parse `user=postgres password=xxxxx host=localhost dbname=fluxci port=%!s(int=5432) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=5432)": invalid syntax)
2021/05/19 13:59:42 [ECHO] POST uri=/install/post/2, status=200, latency=3.035398ms:

MySql/MariaDB works with default values. No issue with SQLite either.

MSSQL gives similar error to postgres:

2021/05/19 14:00:56 /root/src/mvoCI/core/models.go:217
[error] failed to initialize database, got error parse "sqlserver://mysql:password@localhost:%!s(int=3306)?database=fluxci": invalid port ":%!s(int=3306)" after host
2021/05/19 14:00:56 [ECHO] POST uri=/install/post/2, status=200, latency=1.826251ms:

Steps taken to reproduce:

  1. Build mvoCI from source with make dist
  2. Run .\mvo --install
  3. Proceed through installation steps until step 2 database
  4. Choose 'PostgreSQL' as the database type and try to submit default values
When trying to add a postgres database connection, receive an int parsing error. Repeatable with the default values. Error created: ``` 2021/05/19 13:59:42 /root/src/mvoCI/core/models.go:217 [error] failed to initialize database, got error cannot parse `user=postgres password=xxxxx host=localhost dbname=fluxci port=%!s(int=5432) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=5432)": invalid syntax) 2021/05/19 13:59:42 [ECHO] POST uri=/install/post/2, status=200, latency=3.035398ms: ``` MySql/MariaDB works with default values. No issue with SQLite either. MSSQL gives similar error to postgres: ``` 2021/05/19 14:00:56 /root/src/mvoCI/core/models.go:217 [error] failed to initialize database, got error parse "sqlserver://mysql:password@localhost:%!s(int=3306)?database=fluxci": invalid port ":%!s(int=3306)" after host 2021/05/19 14:00:56 [ECHO] POST uri=/install/post/2, status=200, latency=1.826251ms: ``` Steps taken to reproduce: 1. Build mvoCI from source with `make dist` 2. Run `.\mvo --install` 3. Proceed through installation steps until step 2 database 4. Choose 'PostgreSQL' as the database type and try to submit default values
Poster

Was just verifying it does the same when building as the under-privledged user, run from the directory I ran make build in.

Same error:

2021/05/19 14:09:30 /home/mvoci/mvoCI/core/models.go:217
[error] failed to initialize database, got error cannot parse `user=postgres password=xxxxx host=localhost dbname=fluxci port=%!s(int=5432) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=5432)": invalid syntax)
2021/05/19 14:09:30 [ECHO] POST uri=/install/post/2, status=200, latency=1.68151ms:

Took a created mvo.cfg from selecting sqlite as the database then edited in the values needed for my postgres connection as follows:

mvo.cfg
...
  "Database": {
    "Provider": "postgres",
    "Username": "mvoci",
    "Password": "xxxxxxxxxxx",
    "Port": 25060,
    "Host": "private-xxxx.db.ondigitalocean.com",
    "Dbname": "mvoci",
    "Filename": "db.sqlite",
    "PostgresSSL": "verify-full"
  },

When running, gives the same error:

2021/05/19 14:16:55 [INFO] main.go:126 Read Configuration ( mvo.cfg ) successfully
2021/05/19 14:16:55 [INFO] main.go:133 Connecting to database:  postgres

2021/05/19 14:16:55 /home/mvoci/src/mvoCI-build/core/models.go:217
[error] failed to initialize database, got error cannot parse `user=mvoci password=xxxxx host=private-db-postgresql-nyc3-73895-do-user-1111761-0.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=25060) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=25060)": invalid syntax)
2021/05/19 14:16:55 [INFO] main.go:136 Cannot connect to database:  cannot parse `user=mvoci password=xxxxx host=private-xxxx.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=25060) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=25060)": invalid syntax)

Thought I'd try entering the port as a string (so with quotes in the mvo.cfg file "Port" = "25060"):

2021/05/19 14:17:22 [INFO] main.go:126 Read Configuration ( mvo.cfg ) successfully
2021/05/19 14:17:22 [INFO] main.go:133 Connecting to database:  postgres

2021/05/19 14:17:22 /home/mvoci/src/mvoCI-build/core/models.go:217
[error] failed to initialize database, got error cannot parse `user=mvoci password=xxxxx host=private-xxxx.db.ondigitalocean.com dbname=mvoci port=%!s(int=0) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=0)": invalid syntax)
2021/05/19 14:17:22 [INFO] main.go:136 Cannot connect to database:  cannot parse `user=mvoci password=xxxxx host=private-db-postgresql-nyc3-73895-do-user-1111761-0.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=0) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=0)": invalid syntax)
Was just verifying it does the same when building as the under-privledged user, run from the directory I ran `make build` in. Same error: ``` 2021/05/19 14:09:30 /home/mvoci/mvoCI/core/models.go:217 [error] failed to initialize database, got error cannot parse `user=postgres password=xxxxx host=localhost dbname=fluxci port=%!s(int=5432) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=5432)": invalid syntax) 2021/05/19 14:09:30 [ECHO] POST uri=/install/post/2, status=200, latency=1.68151ms: ``` --- Took a created mvo.cfg from selecting sqlite as the database then edited in the values needed for my postgres connection as follows: ``` mvo.cfg ... "Database": { "Provider": "postgres", "Username": "mvoci", "Password": "xxxxxxxxxxx", "Port": 25060, "Host": "private-xxxx.db.ondigitalocean.com", "Dbname": "mvoci", "Filename": "db.sqlite", "PostgresSSL": "verify-full" }, ``` When running, gives the same error: ``` 2021/05/19 14:16:55 [INFO] main.go:126 Read Configuration ( mvo.cfg ) successfully 2021/05/19 14:16:55 [INFO] main.go:133 Connecting to database: postgres 2021/05/19 14:16:55 /home/mvoci/src/mvoCI-build/core/models.go:217 [error] failed to initialize database, got error cannot parse `user=mvoci password=xxxxx host=private-db-postgresql-nyc3-73895-do-user-1111761-0.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=25060) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=25060)": invalid syntax) 2021/05/19 14:16:55 [INFO] main.go:136 Cannot connect to database: cannot parse `user=mvoci password=xxxxx host=private-xxxx.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=25060) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=25060)": invalid syntax) ``` Thought I'd try entering the port as a string (so with quotes in the mvo.cfg file `"Port" = "25060"`): ``` 2021/05/19 14:17:22 [INFO] main.go:126 Read Configuration ( mvo.cfg ) successfully 2021/05/19 14:17:22 [INFO] main.go:133 Connecting to database: postgres 2021/05/19 14:17:22 /home/mvoci/src/mvoCI-build/core/models.go:217 [error] failed to initialize database, got error cannot parse `user=mvoci password=xxxxx host=private-xxxx.db.ondigitalocean.com dbname=mvoci port=%!s(int=0) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=0)": invalid syntax) 2021/05/19 14:17:22 [INFO] main.go:136 Cannot connect to database: cannot parse `user=mvoci password=xxxxx host=private-db-postgresql-nyc3-73895-do-user-1111761-0.a.db.ondigitalocean.com dbname=mvoci port=%!s(int=0) sslmode=verify-full`: invalid port (strconv.ParseUint: parsing "%!s(int=0)": invalid syntax) ```
Poster

I think it's a simple fix. Will submit a pull request.

I think it's a simple fix. Will submit a pull request.
Owner

Thank you! I merged the PR.

Thank you! I merged the PR.
snaums closed this issue 8 months ago
Sign in to join this conversation.
Loading…
There is no content yet.