Confirm the workspace slug resolves on the server under the target org. 404s surface as a clean slug-specific message; other failures (network, auth, wrong org) bubble through so the user can distinguish problems.
(org_slug: &str, workspace_slug: &str)
| 182 | /// 404s surface as a clean slug-specific message; other failures (network, |
| 183 | /// auth, wrong org) bubble through so the user can distinguish problems. |
| 184 | fn verify_workspace_exists(org_slug: &str, workspace_slug: &str) -> CliResult<()> { |
| 185 | let rt = tokio::runtime::Runtime::new() |
| 186 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {e}")))?; |
| 187 | |
| 188 | rt.block_on(async { |
| 189 | let (client, _resolved) = build_client_with_org(Some(org_slug), None).await?; |
| 190 | match client.get_workspace(workspace_slug).await { |
| 191 | Ok(_) => Ok(()), |
| 192 | Err(e) if e.is_not_found() => Err(CliError::InvalidArgument { |
| 193 | message: format!( |
| 194 | "Workspace '{workspace_slug}' not found in org '{org_slug}'.\n \ |
| 195 | Check the slug with: atomic workspace list --org {org_slug}\n \ |
| 196 | Or pass --no-verify to set the value without checking." |
| 197 | ), |
| 198 | }), |
| 199 | Err(e) => Err(remote_err(e)), |
| 200 | } |
| 201 | }) |
| 202 | } |
| 203 | |
| 204 | #[cfg(test)] |
| 205 | mod tests { |
nothing calls this directly
no test coverage detected