fix(database): make database link usable (crash + port type + payload key)#105
Open
heathweaver wants to merge 2 commits into
Open
fix(database): make database link usable (crash + port type + payload key)#105heathweaver wants to merge 2 commits into
database link usable (crash + port type + payload key)#105heathweaver wants to merge 2 commits into
Conversation
`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>
database link usable (crash + port type)database link usable (crash + port type + payload key)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
deno deploy database linkis 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/--portare declaredconflicts: ["connectionString"], butconnectionStringis a positional argument, not an option. Cliffy'sconflictsonly accepts option names, so validation throwsUnknown conflicting option "connectionString"before any input is processed — every form crashes, includingdatabase link --help.Fix: remove the invalid
conflicts(and therequired: trueon--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: coerceportto a number when buildingconnectionConfig.Bug 3 — wrong payload key for createInstance
With ports fixed,
--dry-runsucceeds but a real link still fails withconnection_config: expected object, received undefined. The dry-run path sendsconnection_config(snake_case) todatabases.testConnection, but the link path sentconnectionConfig(camelCase) todatabases.createInstance. The backend expects snake_case. Fix: useconnection_configin the createInstance call too.Verification
Against a real Postgres, all paths now work:
deno fmtanddeno lintpass on the changed file.