You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk psql parses psql's aligned table output without -X, so a user's ~/.psqlrc silently changes what rtk reads #3395
rtk psql parses psql's human-readable aligned table — | column separators, ^[-+]+$ rules, and a (N rows) footer — but it does not pass -X, so psql still executes the user's ~/.psqlrc first. Any \pset in there changes the format rtk is parsing.
Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). Source read only — psql is not installed on this machine, so I have not run the failing cases.
Source
src/cmds/cloud/psql_cmd.rs:29-45 (run) builds the command and injects no flags.
:111 and :19/:63 implement the parse: is_table_format looks for the | separator and the [-+]+ rule line, and the summary keys off (N rows).
What breaks it
~/.psqlrc is honoured.\pset border 0 or \pset border 2, \pset format wrapped|csv|html, \pset fieldsep, or \pset linestyle unicode all change the output shape. linestyle unicode emits │ and ─ instead of | and -, so is_table_format stops recognising the output as a table at all.
(N rows) is translated. It goes through NLS, so on a server or client with a non-English lc_messages the footer text differs and the row-count summary misses.
A literal | inside a cell shifts the columns. The parse splits the line on |, so a value containing a pipe produces an extra column — the row is rendered with fields shifted rather than failing to parse. That is the case I would worry about most: a wrong answer rather than a fallback.
Suggested directions (untested — no programmer has reviewed these)
psql documents machine-readable modes that do not depend on user configuration:
--csv (PostgreSQL 12+), or
-A -t -F$'\t' (unaligned, tuples-only, explicit field separator)
plus -X to skip the startup file regardless of which output mode is chosen. rtk already injects machine-format flags with user-override detection for many other tools (go test -json, kubectl -o json, docker --format, eslint -f json, ruff/pylint --output-format, glab ci list -F json), so this would follow the existing pattern rather than introduce one.
If parsing the aligned format is deliberate — for example to preserve exactly what a user would have seen — then -X alone would still remove the ~/.psqlrc variable.
rtk psql doesn't pass -X (or a machine-readable output mode) to psql, so a user's ~/.psqlrc can silently change table formatting and cause misparsed/shifted columns; add -X plus --csv or -A -t -F flags following rtk's existing machine-format-injection pattern.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/cmds/cloud/psql_cmd.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Activity
pszymkowiak commentedon Aug 4, 2026
🔍 Automated Triage
bughighSummary
rtk psql doesn't pass -X (or a machine-readable output mode) to psql, so a user's ~/.psqlrc can silently change table formatting and cause misparsed/shifted columns; add -X plus --csv or -A -t -F flags following rtk's existing machine-format-injection pattern.
📁 Relevant files
src/cmds/cloud/psql_cmd.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
nightcityblade commentedon Aug 9, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.
HetCreep commentedon Aug 9, 2026
Sounds good — go for it. Happy to take a look once the PR is up.