MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / verify_org_exists

Function verify_org_exists

atomic-cli/src/commands/org/set.rs:151–172  ·  view source on GitHub ↗

Confirm the slug resolves to an org on the server. Returns a [`CliError::InvalidArgument`] with a clean, slug-specific message on 404 so the user sees the actual problem (typo) rather than a raw HTTP response. Other failures (network, auth) bubble up so the user can distinguish "wrong slug" from "server unreachable".

(slug: &str)

Source from the content-addressed store, hash-verified

149/// a raw HTTP response. Other failures (network, auth) bubble up so the
150/// user can distinguish "wrong slug" from "server unreachable".
151fn verify_org_exists(slug: &str) -> CliResult<()> {
152 let rt = tokio::runtime::Runtime::new()
153 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {e}")))?;
154
155 rt.block_on(async {
156 let (client, _resolved) = build_client_with_org(Some(slug), None).await?;
157 match atomic_teams::org::get_org(&client, slug).await {
158 Ok(_) => Ok(()),
159 Err(e) if is_org_not_found(&e) => Err(CliError::InvalidArgument {
160 message: format!(
161 "Organization '{slug}' not found on the server.\n \
162 Check the slug with: atomic org list\n \
163 Or pass --no-verify to set the value without checking."
164 ),
165 }),
166 Err(e) => Err(CliError::RemoteError {
167 message: e.to_string(),
168 url: None,
169 }),
170 }
171 })
172}
173
174fn is_org_not_found(err: &atomic_teams::TeamsError) -> bool {
175 matches!(err, atomic_teams::TeamsError::OrgNotFound(_))

Callers

nothing calls this directly

Calls 3

build_client_with_orgFunction · 0.85
get_orgFunction · 0.85
is_org_not_foundFunction · 0.85

Tested by

no test coverage detected