{"record":{"id":"35eabc3d1f1a48ac","repo":"xai-org/grok-build","slug":"no-target-specified","errorCode":null,"errorMessage":"no target specified","messagePattern":"no target specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/ptyctl-cli/src/cli.rs","lineNumber":225,"sourceCode":"}\n\nimpl Target {\n    /// Resolve target to a base URL.\n    pub fn to_url(&self) -> anyhow::Result<String> {\n        if let Some(ref h) = self.host {\n            if h.starts_with(\"http\") {\n                return Ok(h.clone());\n            }\n            return Ok(format!(\"http://{h}\"));\n        }\n        if let Some(p) = self.port {\n            return Ok(format!(\"http://127.0.0.1:{p}\"));\n        }\n        if let Some(ref n) = self.name {\n            let info = crate::registry::lookup_session(n)?;\n            return Ok(format!(\"http://127.0.0.1:{}\", info.port));\n        }\n        anyhow::bail!(\"no target specified\")\n    }\n}\n","sourceCodeStart":207,"sourceCodeEnd":228,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/ptyctl-cli/src/cli.rs#L207-L228","documentation":"to_url() builds the HTTP base URL for a ptyctl session target. It accepts an explicit port or a session name resolved via the registry; if neither is provided it has no way to know which server to talk to, so it fails with this error.","triggerScenarios":"Calling to_url() (directly or via any command in the ptyctl CLI) when neither a port nor a --name/session name was specified on the CLI or in the resolved options struct.","commonSituations":"Running `ptyctl keys ...`, `screen`, `stop`, etc. without `--name <session>` (or an explicit port); scripting against the CLI after dropping the session-name argument; defaults missing from a wrapper script.","solutions":["Pass the session name, e.g. `ptyctl --name mysession screen`","Pass an explicit port (`--port <p>` or equivalent) if you know the server's port","Run `ptyctl list` (or inspect the registry dir) to find the session name, then retry with --name","In code, ensure the target struct has either `name` or port set before calling to_url()"],"exampleFix":"// before\nptyctl screen --format text\n// after\nptyctl --name dev-session screen --format text","handlingStrategy":"validation","validationCode":"fn validate_target(name: Option<&str>, port: Option<u16>) -> Result<(), String> {\n    if name.is_none() && port.is_none() {\n        return Err(\"no target: pass --name <session> or --port <port>\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --name when scripting ptyctl commands","Wrap common invocations in shell functions that default the session name","Check `ptyctl list` output before issuing name-based commands"],"tags":["cli","missing-argument","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}