runtime: normalize structured secret errors

This commit is contained in:
a.tolmachev
2026-04-19 21:25:28 +00:00
parent 899440fd8a
commit 5debf4dd05
7 changed files with 85 additions and 25 deletions
+12
View File
@@ -2169,6 +2169,7 @@ impl AdminService {
.get_auth_profile(workspace_id, auth_profile_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load auth profile",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingAuthProfile {
@@ -2207,6 +2208,7 @@ impl AdminService {
streaming.max_session_lifetime_ms.unwrap_or(60_000) as i64,
))
.ok_or_else(|| RuntimeError::SecretCrypto {
operation: "compute stream session expiration",
details: "failed to compute stream session expiration".to_owned(),
})?;
let session = StreamSession {
@@ -2234,6 +2236,7 @@ impl AdminService {
.create_stream_session(CreateStreamSessionRequest { session: &session })
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "persist stream session",
details: error.to_string(),
})?;
@@ -2267,6 +2270,7 @@ impl AdminService {
streaming.max_session_lifetime_ms.unwrap_or(300_000) as i64,
))
.ok_or_else(|| RuntimeError::SecretCrypto {
operation: "compute async job expiration",
details: "failed to compute async job expiration".to_owned(),
})?;
let job = AsyncJobHandle {
@@ -2287,6 +2291,7 @@ impl AdminService {
.create_async_job(CreateAsyncJobRequest { job: &job })
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "persist async job",
details: error.to_string(),
})?;
@@ -2376,6 +2381,7 @@ impl AdminService {
.get_secret(workspace_id, secret_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load secret",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingSecret {
@@ -2386,6 +2392,7 @@ impl AdminService {
.get_current_secret_version(workspace_id, secret_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load current secret version",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingSecretVersion {
@@ -2400,6 +2407,7 @@ impl AdminService {
.touch_secret(workspace_id, secret_id, &used_at)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "touch secret",
details: error.to_string(),
})?;
secrets.insert(secret_id.clone(), plaintext);
@@ -4648,6 +4656,7 @@ async fn resolve_runtime_auth_for_task(
.get_auth_profile(workspace_id, auth_profile_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load auth profile",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingAuthProfile {
@@ -4662,6 +4671,7 @@ async fn resolve_runtime_auth_for_task(
.get_secret(workspace_id, secret_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load secret",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingSecret {
@@ -4671,6 +4681,7 @@ async fn resolve_runtime_auth_for_task(
.get_current_secret_version(workspace_id, secret_id)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "load current secret version",
details: error.to_string(),
})?
.ok_or_else(|| RuntimeError::MissingSecretVersion {
@@ -4685,6 +4696,7 @@ async fn resolve_runtime_auth_for_task(
.touch_secret(workspace_id, secret_id, &used_at)
.await
.map_err(|error| RuntimeError::SecretCrypto {
operation: "touch secret",
details: error.to_string(),
})?;
secrets.insert(secret_id.clone(), plaintext);