Skip to content

fix(database): make database link usable (crash + port type + payload key)#105

Open
heathweaver wants to merge 2 commits into
denoland:mainfrom
heathweaver:fix/database-link-conflicts-and-port
Open

fix(database): make database link usable (crash + port type + payload key)#105
heathweaver wants to merge 2 commits into
denoland:mainfrom
heathweaver:fix/database-link-conflicts-and-port

Conversation

@heathweaver

@heathweaver heathweaver commented Jun 23, 2026

Copy link
Copy Markdown

What

deno deploy database link is currently unusable. This makes it work end to end. It turned out to be three distinct bugs, each blocking the one after it.

Fixes #104.

Bug 1 — unconditional crash

--hostname/--username/--password/--port are declared conflicts: ["connectionString"], but connectionString is a positional argument, not an option. Cliffy's conflicts only accepts option names, so validation throws Unknown conflicting option "connectionString" before any input is processed — every form crashes, including database link --help.

Fix: remove the invalid conflicts (and the required: true on --hostname, which otherwise makes the connection-string form impossible), and validate the connection-string-vs-flags mutual exclusion manually in the action.

Bug 2 — port sent as a string

With the crash fixed, the backend rejects the request: port: expected number, received string. Both --port <number> (cliffy treats <number> as a value label, not a type coercion) and the parsed connection-string port arrive as strings. Fix: coerce port to a number when building connectionConfig.

Bug 3 — wrong payload key for createInstance

With ports fixed, --dry-run succeeds but a real link still fails with connection_config: expected object, received undefined. The dry-run path sends connection_config (snake_case) to databases.testConnection, but the link path sent connectionConfig (camelCase) to databases.createInstance. The backend expects snake_case. Fix: use connection_config in the createInstance call too.

Verification

Against a real Postgres, all paths now work:

$ deno run -A main.ts database link --dry-run my-db --hostname db.example.com --port 5432 --username u --password '***'
✔ Connection test successful.

$ deno run -A main.ts database link --dry-run my-db "postgresql://u:***@db.example.com:5432/db"
✔ Connection test successful.

$ deno run -A main.ts database link my-db "postgresql://u:***@db.example.com:5432/db"
✔ Successfully linked database 'my-db'.

deno fmt and deno lint pass on the changed file.

`database link` crashed unconditionally with `Unknown conflicting option
"connectionString"`. The --hostname/--username/--password/--port options
declared `conflicts: ["connectionString"]`, but `connectionString` is a
positional argument, not an option, and cliffy's `conflicts` only accepts
option names — so validation threw before any input was processed, breaking
every invocation including `--help`.

Remove the invalid `conflicts` (and the now-incorrect `required` on
--hostname, which made the connection-string form impossible), and validate
the connection-string-vs-flags mutual exclusion manually in the action.

This surfaced a second bug: `port` was sent to the backend as a string
(`expected number, received string`), so coerce it to a number.

Verified `database link --dry-run` now succeeds against a real Postgres in
both the --hostname/--port and connection-string forms.

Fixes denoland#104

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The link path sent `connectionConfig` (camelCase) to
`databases.createInstance`, while the dry-run path sends `connection_config`
(snake_case) to `databases.testConnection`. The backend expects snake_case,
so a real link failed with `connection_config: expected object, received
undefined` even though --dry-run succeeded. Use the same snake_case key.

Verified: `database link <name> <connStr>` now returns
"Successfully linked database" against a real Postgres.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@heathweaver heathweaver changed the title fix(database): make database link usable (crash + port type) fix(database): make database link usable (crash + port type + payload key) Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

database link crashes: Unknown conflicting option "connectionString"

1 participant