Emit structured local runtime errors in JSON mode - #510
Conversation
a198463 to
94ecf57
Compare
133d21b to
6774653
Compare
There was a problem hiding this comment.
🟠 High local/postgres.rs:107
A stopped existing instance cannot be resumed when the caller supplies an occupied --port; preflight_start_options returns PostgresValidation before start reaches resume_existing. The resume path intentionally ignores supplied settings and uses the stored port, so defer explicit-port availability validation until the fresh-create path.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @crates/clickhousectl/src/local/postgres.rs around line 107:
A stopped existing instance cannot be resumed when the caller supplies an occupied `--port`; `preflight_start_options` returns `PostgresValidation` before `start` reaches `resume_existing`. The resume path intentionally ignores supplied settings and uses the stored port, so defer explicit-port availability validation until the fresh-create path.
There was a problem hiding this comment.
No change. The earlier PR #486 review deliberately retained validation of supplied ports before recovery/Docker work per issue #460. Resume defers auto-selection only when --port is omitted; an occupied explicit port is an invalid invocation even if the stored instance would otherwise resume with a different binding. Existing regressions pin both behaviors.
0c41500 to
c4ad7bd
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9d275eb. Configure here.
| } | ||
| if std::net::TcpListener::bind(("127.0.0.1", p)).is_err() { | ||
| return Err(Error::PostgresValidation(format!( | ||
| return Err(Error::PostgresPortInUse(format!( |
There was a problem hiding this comment.
Postgres port exhaustion wrong code
Medium Severity
When Postgres auto-selection cannot find a free port, the failure is still raised as PostgresRuntime, so structured mode maps it to local_error with a generic Postgres message. The same exhaustion case for ClickHouse was converted to PortInUse and correctly emits port_in_use, so agents cannot classify this Postgres failure under the documented port code.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 9d275eb. Configure here.
|
Superseded by #556 in stack #563. |


Summary
--jsonand detected-agent mode while leaving stdout emptyCloses #475
Schema
{ "error": { "code": "server_not_found", "message": "Server 'default' not found", "command": "clickhousectl local server list" } }The README pins the full code set:
server_not_found,server_not_running,server_running,invalid_version,version_unavailable,port_in_use,startup_exit,startup_timeout,download_failed,io_error, and bounded fallbacklocal_error. Progress is silent in structured mode so stderr remains one JSON object on failure. Clap usage errors and native protocol/child output remain outside the envelope.Verification
cargo fmt --all --checkcargo build -p clickhousectlcargo check -p clickhousectl --no-default-featurescargo test -p clickhousectl(776 passed)cargo clippy -p clickhousectl --all-targets -- -D warningsStack
issue-470-local-client-query-multiplicity)