tbls icon indicating copy to clipboard operation
tbls copied to clipboard

Error parse DSN in postgres if the password has '#' character

Open carvalab opened this issue 2 years ago • 1 comments

What happened

If the password contains the character '#', the parse don't work

What you expected to happened

Connect to database

What stack trace or error message from tbls did you see?

parse "pg://postgres:passw": invalid port ":passw" after host

github.com/k1LoW/tbls/datasource.Analyze
	/Users/runner/work/tbls/tbls/datasource/datasource.go:57

Anything else we need to know?

Environment

  • tbls version 1.60.0
  • Database version postgres 12
  • OS ( Ubuntu bionic, macOS Calalina, WSL2, etc ) macOS Ventura
  • Shell ( bash, zsh, poworshell, etc ) zsh
  • Stacktrace or error message from tbls ( If you can, set DEBUG=1)
parse "pg://postgres:passw": invalid port ":passw" after host
github.com/k1LoW/tbls/datasource.Analyze
	/Users/runner/work/tbls/tbls/datasource/datasource.go:57
github.com/k1LoW/tbls/cmd.glob..func7
	/Users/runner/work/tbls/tbls/cmd/out.go:77
github.com/spf13/cobra.(*Command).execute
	/Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:916
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044
github.com/spf13/cobra.(*Command).Execute
	/Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/k1LoW/tbls/cmd.Execute
	/Users/runner/work/tbls/tbls/cmd/root.go:191
main.main
	/Users/runner/work/tbls/tbls/main.go:34
runtime.main
	/usr/local/Cellar/go/1.19.5/libexec/src/runtime/proc.go:250
runtime.goexit
	/usr/local/Cellar/go/1.19.5/libexec/src/runtime/asm_amd64.s:1594
  • Config ( .tbls.yml )
# DSN (Database Source Name) to connect database
dsn: pg://postgres:passw#rd@localhost:5432/test_db

carvalab avatar Feb 02 '23 22:02 carvalab

# is the syntax for YAML comments and is not a valid URL.

You might want to surround the DSN with a single quart and urlencode.

dsn: 'pg://postgres:passw%23rd@localhost:5432/test_db'

k1LoW avatar Feb 02 '23 23:02 k1LoW