Skip to main content

systemprompt_ai/services/upstream/
error.rs

1//! Failures resolving a catalog provider into a sendable upstream.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use systemprompt_security::credential::CredentialError;
7use systemprompt_traits::BoxedSource;
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum UpstreamTargetError {
12    #[error("secrets are not available: {0}")]
13    SecretsUnavailable(#[source] BoxedSource),
14
15    #[error("provider '{provider}' secret '{secret}' is not configured")]
16    MissingSecret { provider: String, secret: String },
17
18    #[error("secret '{secret}' declares a Google service account but is malformed: {source}")]
19    MalformedCredential {
20        secret: String,
21        #[source]
22        source: CredentialError,
23    },
24
25    #[error(
26        "provider '{provider}' is hosted on Vertex AI, which accepts only a Google service-account \
27         key for this wire; secret '{secret}' holds an API key"
28    )]
29    ApiKeyOnVertex { provider: String, secret: String },
30
31    #[error("provider '{provider}' endpoint cannot be resolved: {source}")]
32    Endpoint {
33        provider: String,
34        #[source]
35        source: CredentialError,
36    },
37
38    #[error("could not mint a Google access token from secret '{secret}': {source}")]
39    Mint {
40        secret: String,
41        #[source]
42        source: CredentialError,
43    },
44}