Skip to content

fix(cli): keep db export stdout clean by routing the banner to stderr - #253

Merged
Brooooooklyn merged 1 commit into
mainfrom
07-04-fix_cli_keep_db_export_stdout_clean_by_routing_the_banner_to_stderr
Jul 4, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
07-04-fix_cli_keep_db_export_stdout_clean_by_routing_the_banner_to_stderr

Conversation

@shulaoda

@shulaoda shulaoda commented Jul 4, 2026

Copy link
Copy Markdown
Member

What

runDbCommand now detects the export action without --output and sends the intro banner (and its leading blank line) to stderr for that mode. runExport sends its three error messages to stderr as well. The SQL dump still goes to stdout via process.stdout.write. Every other db subcommand is unchanged.

Why

void db export without --output streams raw SQL to stdout so it can be piped or redirected, for example void db export > dump.sql or void db export | sqlite3 new.db. But the command printed the clack intro banner first, and clack writes to stdout by default, so the dump began with a blank line and a void db banner before the first CREATE TABLE. Feeding that file into sqlite3 fails with a parse error on the banner line and the restore never runs. Errors raised during a piped export were also written into the dump and hidden from the user, so routing them to stderr both keeps the dump clean and makes the error visible on the terminal.

Safety

The change is scoped to the export to stdout path. Other db subcommands keep their banner and status on stdout exactly as before, and void db export --output file.sql is unaffected because that path does not stream to stdout. The banner still appears on the terminal in every case, since stderr is not redirected by a stdout pipe.

Verification

A new regression test at packages/void/test/unit/db-export-stdout.test.ts drives runDbCommand with the real clack library and a mocked SQLite layer, then asserts that stdout is byte for byte the SQL dump and that the banner lands on stderr. It fails on the old code, where stdout starts with the banner, and passes on the fix. The db-migrate, db-seed, and db-commands suites that assert exact clack arguments stay green (33 tests total), and the void package typechecks with tsgo and passes oxlint.

@Brooooooklyn
Brooooooklyn merged commit 8522299 into main Jul 4, 2026
7 checks passed
@Brooooooklyn
Brooooooklyn deleted the 07-04-fix_cli_keep_db_export_stdout_clean_by_routing_the_banner_to_stderr branch July 4, 2026 12:31
cpojer pushed a commit that referenced this pull request Sep 11, 2026
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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