Skip to content

Commit 1eebfe2

Browse files
committed
fix(cortex-cli): show user-friendly error for invalid --host value
Fixes bounty issue #1559 When running 'cortex acp --host not.valid', the command previously showed a raw syntax error 'invalid socket address syntax'. This change validates the host parameter as a valid IP address before attempting to parse it and provides a clear error message with expected format hint.
1 parent 8f839ec commit 1eebfe2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

cortex-cli/src/acp_cmd.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! The ACP protocol enables IDE integration (like Zed) with Cortex.
44
//! Supports both stdio and HTTP transports for flexible integration.
55
6-
use anyhow::Result;
6+
use anyhow::{Result, bail};
77
use clap::Parser;
8-
use std::net::SocketAddr;
8+
use std::net::{IpAddr, SocketAddr};
99
use std::path::PathBuf;
1010

1111
/// ACP server CLI command.
@@ -76,6 +76,14 @@ impl AcpCli {
7676

7777
/// Run ACP server with HTTP transport.
7878
async fn run_http_server(&self, config: cortex_engine::Config) -> Result<()> {
79+
// Validate host is a valid IP address before attempting to parse
80+
if self.host.parse::<IpAddr>().is_err() {
81+
bail!(
82+
"Invalid host '{}'. Expected a valid IP address (e.g., 127.0.0.1 or 0.0.0.0)",
83+
self.host
84+
);
85+
}
86+
7987
let addr: SocketAddr = format!("{}:{}", self.host, self.port).parse()?;
8088

8189
eprintln!("Starting ACP server on http://{}", addr);

0 commit comments

Comments
 (0)