Hmbown/CodeWhale · error
Port must be > 0
Error message
Port must be > 0
What it means
`validate_runtime_listener_security` rejects a Runtime API port of 0 because the mobile/control HTTP listener needs an actual deterministic port; port 0 (OS-assigned ephemeral) is not accepted for this secured surface.
Solutions
- Pass an explicit port > 0, e.g. --port 8080
- Fix the config value that sets port to 0
- Check for a shell variable expanding empty/0 into the flag
Example fix
// before codewhale runtime --port 0 // after codewhale runtime --port 8080
Defensive patterns
Strategy: validation
Validate before calling
if port <= 0 { return Err("Runtime API port must be an explicit positive integer".into()); } Prevention
- Never pass --port 0 to the runtime API
- Read ports from config with a positive-integer default
- Validate numeric flags before constructing RuntimeApiOptions
When it happens
Trigger: Starting the Runtime API with `RuntimeApiOptions.port == 0`, typically from a CLI flag like `--port 0` or a config value defaulting to 0.
Common situations: Copy-pasting a dev config where the port was never set; assuming port 0 means 'pick any free port' as with ordinary TCP servers.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- unsupported permission posture
- unsupported Runtime mode
- 1
- A pinned task provider requires an explicit model
- A positive pull request number is required
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/5750367b74534415.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_api.rs:1104
}
let serve_result = axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await
.map_err(|e| anyhow!("Runtime API server error: {e}"));
scheduler_cancel.cancel();
scheduler_handle.abort();
task_manager.shutdown_and_wait().await?;
serve_result
}
/// Mobile control uses plain HTTP only on loopback. It has no TLS or verified
/// overlay transport, so a non-loopback listener would expose the Runtime API
/// to peers that can observe or replay browser traffic.
fn validate_runtime_listener_security(options: &RuntimeApiOptions) -> Result<()> {
if options.port == 0 {
bail!("Port must be > 0");
}
if options.web && options.host != "127.0.0.1" {
bail!("Codewhale web is loopback-only and must bind to 127.0.0.1");
}
if options.web && options.insecure_no_auth {
bail!("Codewhale web requires Runtime authentication; remove --insecure");
}
if options.mobile && !is_loopback_bind_host(&options.host) {
bail!(
"Codewhale mobile is loopback-only without TLS or a verified overlay; bind to 127.0.0.1 or ::1"
);
}
if options.insecure_no_auth && !is_loopback_bind_host(&options.host) {
bail!(
"Unauthenticated Runtime access is loopback-only; remove --insecure or bind to 127.0.0.1 or ::1"
);
}
Ok(())View on GitHub (pinned to 73e0f67d83)