1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
use alien_error::AlienErrorData;
use serde::{Deserialize, Serialize};
/// Represents common infrastructure errors across multiple cloud platforms.
#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum ErrorData {
/// Invalid or malformed platform configuration.
#[error(
code = "INVALID_client_config",
message = "Invalid platform configuration: {message}",
retryable = "false",
internal = "false"
)]
InvalidClientConfig {
/// Human-readable description of the configuration issue
message: String,
/// Additional error details if available
errors: Option<String>,
},
/// Authentication with cloud provider failed.
#[error(
code = "AUTHENTICATION_ERROR",
message = "Authentication failed: {message}",
retryable = "true",
internal = "false"
)]
AuthenticationError {
/// Human-readable description of the authentication failure
message: String,
},
/// The manager answered a runtime credential exchange with a refusal (a 4xx status).
///
/// Unlike a transport failure or a server error, asking again gives the same answer until an
/// operator changes the grant, so it is not retried.
#[error(
code = "RUNTIME_AUTHORITY_REFUSED",
message = "Runtime authority refused: {message}",
retryable = "false",
internal = "false"
)]
RuntimeAuthorityRefused {
/// What the manager answered
message: String,
},
/// The requested resource does not exist.
#[error(
code = "REMOTE_RESOURCE_NOT_FOUND",
message = "{resource_type} '{resource_name}' not found",
retryable = "true",
internal = "false",
http_status_code = 404
)]
RemoteResourceNotFound {
/// Type of the resource that was not found
resource_type: String,
/// Name of the resource that was not found
resource_name: String,
},
/// An existing cloud object does not belong to the runtime resource being written.
#[error(
code = "EXISTING_CLOUD_RESOURCE_NOT_OWNED",
message = "{object} is not managed by this deployment's runtime resource '{resource_id}'; reconcile ownership in setup before changing it.",
retryable = "false",
internal = "false",
http_status_code = 409
)]
ExistingCloudResourceNotOwned { resource_id: String, object: String },
/// Operation conflicts with current resource state (e.g., resource already exists, concurrent modifications, etag mismatch).
#[error(
code = "REMOTE_RESOURCE_CONFLICT",
message = "Conflict with {resource_type} '{resource_name}': {message}",
retryable = "true",
internal = "false"
)]
RemoteResourceConflict {
/// Type of the resource that has a conflict
resource_type: String,
/// Name of the resource that has a conflict
resource_name: String,
/// Human-readable description of the specific conflict
message: String,
},
/// Access denied due to insufficient permissions.
#[error(
code = "REMOTE_ACCESS_DENIED",
message = "Access denied to {resource_type} '{resource_name}'",
retryable = "true",
internal = "false"
)]
RemoteAccessDenied {
/// Type of the resource access was denied to
resource_type: String,
/// Name of the resource access was denied to
resource_name: String,
},
/// Request rate limit exceeded.
#[error(
code = "RATE_LIMIT_EXCEEDED",
message = "Rate limit exceeded: {message}",
retryable = "true",
internal = "false"
)]
RateLimitExceeded {
/// Human-readable description of the rate limit context
message: String,
},
/// Operation exceeded the allowed timeout.
#[error(
code = "TIMEOUT",
message = "Operation timed out: {message}",
retryable = "true",
internal = "false"
)]
Timeout {
/// Human-readable description of what operation timed out
message: String,
},
/// Service is temporarily unavailable.
#[error(
code = "REMOTE_SERVICE_UNAVAILABLE",
message = "Service unavailable: {message}",
retryable = "true",
internal = "false"
)]
RemoteServiceUnavailable {
/// Human-readable description of the service unavailability
message: String,
},
/// Quota or resource limits have been exceeded.
#[error(
code = "QUOTA_EXCEEDED",
message = "Quota exceeded: {message}",
retryable = "true",
internal = "false"
)]
QuotaExceeded {
/// Human-readable description of what quota was exceeded
message: String,
},
/// A resource reached the provider's cap on how many versions it can hold. Waiting does not
/// clear it: a version has to be deleted, so a blind retry only repeats the refusal.
#[error(
code = "VERSION_LIMIT_EXCEEDED",
message = "Version limit reached: {message}",
retryable = "false",
internal = "false"
)]
VersionLimitExceeded {
/// Human-readable description of the limit and the resource that reached it
message: String,
},
/// A remote asynchronous operation finished unsuccessfully; its handle cannot recover.
/// Retrying the issuing handler can reissue the operation, so preserve executor retries.
/// Callers that persist handles must recognize this variant and stop polling the old handle.
#[error(
code = "REMOTE_OPERATION_FAILED",
message = "{operation} for '{resource_name}' finished with status {status}: {message}",
retryable = "true",
internal = "true"
)]
RemoteOperationFailed {
/// Operation that finished unsuccessfully.
operation: String,
/// Resource associated with the operation.
resource_name: String,
/// Terminal status reported by the provider.
status: String,
/// Provider error code, when supplied.
provider_code: Option<String>,
/// Provider diagnostics, including its message and any nested error details.
message: String,
},
/// Network or request-level failure when sending HTTP request.
#[error(
code = "HTTP_REQUEST_FAILED",
message = "{message}",
retryable = "true",
internal = "false"
)]
HttpRequestFailed {
/// Human-readable description of the HTTP request failure
message: String,
},
/// Body cleanup failed after the service accepted the request.
#[error(
code = "HTTP_RESPONSE_BODY_READ_FAILED",
message = "HTTP {http_status} succeeded, but its response body could not be read",
retryable = "false",
internal = "false",
hint = "The request was already accepted. Check the remote state before retrying."
)]
HttpResponseBodyReadFailed {
/// Successful HTTP status received before the body read failed.
http_status: u16,
},
/// HTTP request succeeded but returned a non-success status code.
#[error(
code = "HTTP_RESPONSE_ERROR",
message = "{message}",
retryable = "true",
internal = "true"
)]
HttpResponseError {
/// Human-readable description of the HTTP response error
message: String,
/// The URL that returned the error
url: String,
/// HTTP status code returned
http_status: u16,
// Request body text
http_request_text: Option<String>,
/// Response body text if available
http_response_text: Option<String>,
},
/// The cloud service rejected the request and returned its own error code and message.
///
/// Unlike [`ErrorData::HttpResponseError`], this is safe to show to users: it holds only the
/// service's code and message, never the request body or the raw response. Wrap the internal
/// `HttpResponseError` with it so those stay available for debugging. Retryability comes from
/// that source, because some rejections are transient (for example, an S3 bucket notification
/// whose target permission has not propagated yet). Only use it for a service whose error
/// messages don't echo submitted values; some APIs repeat request fields, including secrets.
#[error(
code = "REMOTE_REQUEST_REJECTED",
message = "{service} rejected the request ({provider_code}): {message}",
retryable = "inherit",
internal = "false"
)]
RemoteRequestRejected {
/// Cloud service that rejected the request (e.g. "S3")
service: String,
/// HTTP status code the service returned
http_status: u16,
/// The service's error code (e.g. "InvalidArgument")
provider_code: String,
/// The service's error message
message: String,
},
/// Failure during signing of an HTTP request (e.g., AWS SigV4).
#[error(
code = "REQUEST_SIGN_ERROR",
message = "Request signing failed: {message}",
retryable = "true",
internal = "true"
)]
RequestSignError {
/// Human-readable description of the signing failure
message: String,
},
/// An extension's interceptor failed, or made a change Alien refuses. The same request fails
/// the same way again, so it is final, unless the interceptor marked a failure before the
/// call was sent retryable, as a hook stopped at its deadline is.
#[error(
code = "INTERCEPTOR_FAILED",
message = "Extension '{extension}' failed the call: {message}",
retryable = "false",
internal = "false"
)]
InterceptorFailed {
/// The extension whose interceptor failed
extension: String,
/// What the interceptor did wrong
message: String,
},
/// A client with interceptors refused to send its credential to an origin other than its
/// own endpoint, such as one a rewritten response named.
#[error(
code = "DESTINATION_REFUSED",
message = "Refused to send a signed request to {url}: this client signs only for {endpoint}",
retryable = "false",
internal = "false"
)]
DestinationRefused {
/// Origin the request was addressed to
url: String,
/// Origin of the client's configured endpoint
endpoint: String,
},
/// Catch-all error
#[error(
code = "GENERIC_ERROR",
message = "{message}",
retryable = "true",
internal = "true"
)]
GenericError {
/// Human-readable description of the error
message: String,
},
/// Invalid or malformed input parameters provided to the operation.
#[error(
code = "INVALID_INPUT",
message = "Invalid input: {message}",
retryable = "false",
internal = "false"
)]
InvalidInput {
/// Human-readable description of what input was invalid
message: String,
/// Optional field name that was invalid
field_name: Option<String>,
},
/// Failed to serialize or deserialize data.
#[error(
code = "SERIALIZATION_ERROR",
message = "Serialization failed: {message}",
retryable = "false",
internal = "true"
)]
SerializationError {
/// Human-readable description of the serialization failure
message: String,
},
/// Failed to load or parse kubeconfig file.
#[error(
code = "KUBECONFIG_ERROR",
message = "Kubeconfig error: {message}",
retryable = "false",
internal = "false"
)]
KubeconfigError {
/// Human-readable description of the kubeconfig error
message: String,
},
/// Failed to load data from base64 or file.
#[error(
code = "DATA_LOAD_ERROR",
message = "Failed to load data: {message}",
retryable = "false",
internal = "false"
)]
DataLoadError {
/// Human-readable description of the data loading failure
message: String,
},
}
/// Convenient alias with default error type `ErrorData`. Allows callers to override the
/// error type when needed while still accepting the common single-generic form `Result<T>`.
pub type Result<T, E = ErrorData> = alien_error::Result<T, E>;
/// Convenience alias representing a constructed AlienError with our `ErrorData` payload.
pub type Error = alien_error::AlienError<ErrorData>;