Wrangler errors if my Hyperdrive > `connectionString` contains an apostrophe
My DB password contains
'
, and therefore so does my local connection string for working with Hyperdrive during development.
This leads to the attached error when running locally - but not if I run with the --remote
flag.
Is this a bug? In my TOML, the connection string is specified within "
, so the value should be able to accommodate '
.8 Replies
Is
'
the only special character in the password?
I would expect /
, ?
and #
to be issues in the password
field - not '
.My apologies - there is indeed a
?
in there too. Not sure why I lazily assumed it would be the apostrophe. I can of course change the password, but it's good to know which characters cause issues.
Thank you!You could probably also percent encode it - Postgres is fine with that.
Aha - good shout. Thanks!
For completeness, there is a PR open that will perform this encoding for you automatically: https://github.com/cloudflare/workers-sdk/pull/4419
That looks like it's just for
hyperdrive create
- I guess they need to also do it in https://github.com/cloudflare/workers-sdk/blob/96faca45733b90ca5b5b2a308c85e2dadeb1c6bf/packages/miniflare/src/plugins/hyperdrive/index.ts#L11Hmmm, that PR seems to include changes to that file? https://github.com/cloudflare/workers-sdk/pull/4419/files#diff-c32974de15c4b55af0ca1bbccfc2b9c4f555d7746eda5dc1162238b5a65a9ca9R74
It looks like the PR wouldn't actually solve the problem that Mitya had in that case is just decoding a percent-encoded URL, but the issue that Mitya had is that it'll fail at
new URL()
anyways unless you manually percent-encode it yourself.
I guess the actual separate issue here is to make a better callout to what the issue is (characters in the password that need percent-encoding)