Skip to content

fix(pgcli): Fix error when initializing pgcli command#31

Open
rgoomar wants to merge 1 commit intorender-oss:mainfrom
rgoomar:fix-pgcli
Open

fix(pgcli): Fix error when initializing pgcli command#31
rgoomar wants to merge 1 commit intorender-oss:mainfrom
rgoomar:fix-pgcli

Conversation

@rgoomar
Copy link

@rgoomar rgoomar commented Mar 18, 2026

Summary

Fix render pgcli failing with Error: flag accessed but not defined: command by bypassing ParseCommand for pgcli's arg parsing. This gets it into a working state.

Motivation

render pgcli is broken — any invocation hits the error because ParseCommand reflects over all cli struct tags on PSQLInput, including Command (tagged cli:"command"), which maps to a --command flag that only psql registers. pgcli is interactive-only and doesn't need that flag.

How to verify

  1. render pgcli --help — should show help without error
  2. render pgcli — should launch interactive database selection
  3. render pgcli <postgres-id-or-name> — should connect directly
  4. render pgcli <postgres-id-or-name> -- --some-pgcli-flag — should pass extra args through
  5. render psql — should still work as before (no regression)

I ran all of these locally with

go build
./cli pgcli

Release notes

Fix `render pgcli` command failing with "flag accessed but not defined: command"

@rgoomar
Copy link
Author

rgoomar commented Mar 24, 2026

Looks like there's this error happening with the copybara-pr job:

Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
      
- render-oss/cli
Error: [@octokit/auth-app] appId option is required
    at createAppAuth (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:47665:11)
    at main (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:47956:17)
    at Object.<anonymous> (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:48079:20)
    at Module._compile (node:internal/modules/cjs/loader:1521:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
    at node:internal/main/run_main_module:28:49


if cmd.ArgsLenAtDash() == 0 {
input.PostgresIDOrName = ""
input.Tool = views.PGCLI

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to set the tool here as this is defined inside InteractivePGCLIView right ?

@manish-render
Copy link

We should keep the ParseCommand invocation somehow as it does sanity checking as well.

With this change, i get a SIGSEGV when i pass -o to render pgcli instead of an error saying interactive mode is not supported for pgcli.

I think pgcli itself also supports few non interactive options like -l and --ping. Since render pgcli integration does not yet support that, one way could be to extend render pgcli as well with the command flag just like psql. That would be decent code churn though.

A mitigation idea can be to try and ignore the error when retrieving a field by adding an optional tag to the command field as well and using this tag presence to skip the error inside ParseCommand (case reflect.String) altogether until there can be a holistic fix.

Let me know what you think. I can take a stab at changes I am suggesting as well.

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.

2 participants