alien-core 3.3.56

Deploy software into your customers' cloud accounts and keep it fully managed
Documentation
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
use alien_error::AlienErrorData;
use serde::{Deserialize, Serialize};

use crate::{Platform, ResourceType};

/// Core error data exposed by the `alien-core` crate.
#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum ErrorData {
    /// An applicable stack input is missing or violates its declared constraints.
    #[error(
        code = "STACK_INPUT_INVALID",
        message = "Stack input '{input_id}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    StackInputInvalid { input_id: String, reason: String },

    /// Federation metadata cannot safely identify the intended trust or target.
    #[error(
        code = "GCP_FEDERATION_INVALID",
        message = "Invalid GCP federation field '{field}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    GcpFederationInvalid { field: String, reason: String },

    /// The image's command identity cannot be resolved safely.
    #[error(
        code = "SANDBOX_IMAGE_USER_INVALID",
        message = "Invalid sandbox image USER '{user}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxImageUserInvalid { user: String, reason: String },
    /// Policy exceeds the portable target-count or canonical JSON size limit.
    #[error(
        code = "SANDBOX_EGRESS_POLICY_TOO_LARGE",
        message = "Sandbox egress policy exceeds {limit}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxEgressPolicyTooLarge { limit: String },

    /// An egress target cannot be enforced safely.
    #[error(
        code = "SANDBOX_EGRESS_INVALID",
        message = "Invalid sandbox egress target '{target}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxEgressInvalid { target: String, reason: String },

    /// An AWS internet sandbox reached template rendering without the egress gateway.
    #[error(
        code = "SANDBOX_INTERNET_GATEWAY_MISSING",
        message = "Sandbox '{sandbox_id}' declares egress 'internet', which routes through the managed sandbox egress gateway, but this stack has no gateway. Prepare the stack with the deployment preflights before rendering its setup template",
        retryable = "false",
        internal = "false"
    )]
    SandboxInternetGatewayMissing { sandbox_id: String },

    /// A deployment selected resources outside the release's declared choices.
    #[error(
        code = "CONTAINER_RESOURCE_SELECTION_INVALID",
        message = "Invalid {dimension} selection for container '{resource_id}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    ContainerResourceSelectionInvalid {
        resource_id: String,
        dimension: String,
        reason: String,
    },
    /// A fallback error when nothing more specific matches.
    #[error(
        code = "GENERIC_ERROR",
        message = "{message}",
        retryable = "true",
        internal = "false"
    )]
    GenericError {
        /// Human-readable description of the error.
        message: String,
    },

    /// Resource type mismatch found during stack operations.
    #[error(
        code = "UNEXPECTED_RESOURCE_TYPE",
        message = "Unexpected resource type for resource '{resource_id}': expected {expected}, but got {actual}",
        retryable = "false",
        internal = "false"
    )]
    UnexpectedResourceType {
        resource_id: String,
        expected: ResourceType,
        actual: ResourceType,
    },

    /// Attempt to update a resource that does not support updates.
    #[error(
        code = "INVALID_RESOURCE_UPDATE",
        message = "Resource '{resource_id}' cannot be updated: {reason}",
        retryable = "false",
        internal = "false"
    )]
    InvalidResourceUpdate { resource_id: String, reason: String },

    /// Worker execution timeout is outside the supported range.
    #[error(
        code = "WORKER_TIMEOUT_INVALID",
        message = "Worker timeoutSeconds must be between 1 and {max_timeout_seconds} seconds, got {timeout_seconds}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    WorkerTimeoutInvalid {
        timeout_seconds: u32,
        max_timeout_seconds: u32,
    },

    /// The resource exists but has not produced any outputs yet.
    #[error(
        code = "RESOURCE_HAS_NO_OUTPUTS",
        message = "Resource '{resource_id}' has no outputs",
        retryable = "true",
        internal = "false"
    )]
    ResourceHasNoOutputs { resource_id: String },

    /// Requested resource absent from the stack state.
    #[error(
        code = "RESOURCE_NOT_FOUND",
        message = "Resource '{resource_id}' not found in stack state. Available resources: {available_resources:?}",
        retryable = "false",
        internal = "false",
        http_status_code = 404
    )]
    ResourceNotFound {
        resource_id: String,
        available_resources: Vec<String>,
    },

    /// Binding configuration is invalid or missing required fields.
    #[error(
        code = "BINDING_CONFIG_INVALID",
        message = "Invalid binding configuration for '{binding_name}': {reason}",
        retryable = "false",
        internal = "false"
    )]
    BindingConfigInvalid {
        binding_name: String,
        reason: String,
    },

    /// Environment variable for binding is missing.
    #[error(
        code = "BINDING_ENV_VAR_MISSING",
        message = "Missing environment variable '{env_var}' for binding '{binding_name}'",
        retryable = "false",
        internal = "false"
    )]
    BindingEnvVarMissing {
        binding_name: String,
        env_var: String,
    },

    /// Failed to parse binding JSON from environment variable.
    #[error(
        code = "BINDING_JSON_PARSE_FAILED",
        message = "Failed to parse binding JSON for '{binding_name}': {reason}",
        retryable = "false",
        internal = "false"
    )]
    BindingJsonParseFailed {
        binding_name: String,
        reason: String,
    },

    /// Unexpected combination of resource statuses when computing stack status.
    #[error(
        code = "UNEXPECTED_RESOURCE_STATUS_COMBINATION",
        message = "Unexpected resource status combination during {operation}: {resource_statuses:?}",
        retryable = "false",
        internal = "true"
    )]
    UnexpectedResourceStatusCombination {
        resource_statuses: Vec<String>,
        operation: String,
    },

    /// External binding type does not match the resource type.
    #[error(
        code = "EXTERNAL_BINDING_TYPE_MISMATCH",
        message = "External binding type mismatch for resource '{resource_id}': expected {expected}, got {actual}",
        retryable = "false",
        internal = "false"
    )]
    ExternalBindingTypeMismatch {
        resource_id: String,
        expected: String,
        actual: String,
    },

    // Presigned request errors
    /// Presigned request has expired.
    #[error(
        code = "PRESIGNED_REQUEST_EXPIRED",
        message = "Presigned request for '{path}' expired at {expired_at}",
        retryable = "false",
        internal = "false"
    )]
    PresignedRequestExpired {
        path: String,
        expired_at: chrono::DateTime<chrono::Utc>,
    },

    /// HTTP request failed.
    #[error(
        code = "HTTP_REQUEST_FAILED",
        message = "HTTP {method} request to '{url}' failed",
        retryable = "true",
        internal = "false"
    )]
    HttpRequestFailed { url: String, method: String },

    /// Operation not supported.
    #[error(
        code = "OPERATION_NOT_SUPPORTED",
        message = "Operation '{operation}' not supported: {reason}",
        retryable = "false",
        internal = "false"
    )]
    OperationNotSupported { operation: String, reason: String },

    /// Local filesystem error.
    #[error(
        code = "LOCAL_FILESYSTEM_ERROR",
        message = "Local filesystem error for '{path}' during {operation}",
        retryable = "false",
        internal = "false"
    )]
    LocalFilesystemError { path: String, operation: String },

    /// Feature not enabled.
    #[error(
        code = "FEATURE_NOT_ENABLED",
        message = "Feature '{feature}' is not enabled",
        retryable = "false",
        internal = "false"
    )]
    FeatureNotEnabled { feature: String },

    /// A resource requires setup capabilities unavailable to automatic management.
    #[error(
        code = "AUTOMATIC_SETUP_RESOURCE_UNSUPPORTED",
        message = "Automatic infrastructure management does not support {resource_type} '{resource_id}' on {platform}; use manual setup",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    AutomaticSetupResourceUnsupported {
        resource_type: String,
        resource_id: String,
        platform: Platform,
    },

    /// A sandbox capability is unavailable on the target platform.
    #[error(
        code = "SANDBOX_CAPABILITY_UNSUPPORTED",
        message = "Sandbox capability '{capability}' is not supported on {platform}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxCapabilityUnsupported {
        /// The capability that was requested
        capability: String,
        /// The platform that does not offer it
        platform: String,
    },

    /// The target platform has no sandbox backend at all.
    #[error(
        code = "SANDBOX_PLATFORM_UNSUPPORTED",
        message = "Sandbox is not available on {platform}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxPlatformUnsupported {
        /// The platform with no sandbox backend
        platform: String,
    },

    /// A bundle signature or signing key was rejected.
    #[error(
        code = "BUNDLE_SIGNATURE_INVALID",
        message = "Bundle signature invalid: {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    BundleSignatureInvalid {
        /// Why the signature or key was rejected
        reason: String,
    },

    /// A sandbox capability was refused.
    #[error(
        code = "SANDBOX_CAPABILITY_REFUSED",
        message = "Sandbox capability refused: {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 403
    )]
    SandboxCapabilityRefused {
        /// Why it was refused. Deliberately coarse — it must not reveal which sandboxes exist.
        reason: String,
    },

    /// A sandbox limit is missing or not a valid quantity.
    #[error(
        code = "SANDBOX_LIMIT_INVALID",
        message = "Sandbox '{resource_id}' has an invalid {field} limit '{value}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    SandboxLimitInvalid {
        /// The sandbox whose limit failed validation
        resource_id: String,
        /// Which limit (cpu, memory, disk, maxProcesses)
        field: String,
        /// The rejected value
        value: String,
        /// Why it was rejected
        reason: String,
    },

    // Commands protocol errors
    /// Invalid Commands envelope.
    #[error(
        code = "INVALID_ENVELOPE",
        message = "Invalid Commands envelope: {message}",
        retryable = "false",
        internal = "false"
    )]
    InvalidEnvelope {
        message: String,
        field: Option<String>,
    },

    /// A command-enabled resource exists but the deployment has no token to
    /// authenticate its command transport.
    #[error(
        code = "COMMAND_TOKEN_MISSING",
        message = "Deployment has command-enabled resource '{resource_id}' but no deployment token to authenticate it: {reason}",
        retryable = "false",
        internal = "false"
    )]
    CommandTokenMissing { resource_id: String, reason: String },

    /// Public URL configuration is invalid.
    #[error(
        code = "PUBLIC_URL_INVALID",
        message = "Invalid public URL for resource '{resource_id}': {reason}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    PublicUrlInvalid { resource_id: String, reason: String },

    /// JSON serialization failed.
    #[error(
        code = "JSON_SERIALIZATION_FAILED",
        message = "Failed to serialize JSON: {reason}",
        retryable = "false",
        internal = "false"
    )]
    JsonSerializationFailed { reason: String },

    /// JSON deserialization failed.
    #[error(
        code = "JSON_DESERIALIZATION_FAILED",
        message = "Failed to deserialize JSON: {reason}",
        retryable = "false",
        internal = "false"
    )]
    JsonDeserializationFailed { reason: String },

    /// Distribution template serialization failed.
    #[error(
        code = "TEMPLATE_SERIALIZATION_FAILED",
        message = "Failed to serialize {format} template: {reason}",
        retryable = "false",
        internal = "true"
    )]
    TemplateSerializationFailed { format: String, reason: String },

    /// A management ExternalId is not 32 to 128 ASCII letters and digits.
    #[error(
        code = "MANAGEMENT_EXTERNAL_ID_INVALID",
        message = "Management ExternalId must be 32 to 128 ASCII letters and digits (got {length} characters)",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    ManagementExternalIdInvalid {
        /// Length of the rejected value. The value itself is never echoed.
        length: usize,
    },

    /// A role ARN a setup template is told to accept as its managing role is
    /// not an IAM role ARN.
    #[error(
        code = "MANAGING_ROLE_ARN_INVALID",
        message = "Managing role ARN '{arn}' is not an IAM role ARN (arn:<partition>:iam::<account>:role/<name>)",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    ManagingRoleArnInvalid {
        /// The rejected ARN.
        arn: String,
    },

    /// ImportData did not match the registered typed payload.
    #[error(
        code = "IMPORT_DATA_INVALID",
        message = "Invalid ImportData for resource '{resource_id}' ({resource_type}) on {platform}",
        retryable = "false",
        internal = "false",
        http_status_code = 400
    )]
    ImportDataInvalid {
        resource_id: String,
        resource_type: ResourceType,
        platform: Platform,
    },

    /// No registry implementation exists for a resource/platform pair.
    #[error(
        code = "IMPORT_REGISTRATION_MISSING",
        message = "Missing {registration_kind} registration for resource type '{resource_type}' on {platform}",
        retryable = "false",
        internal = "true"
    )]
    ImportRegistrationMissing {
        resource_type: ResourceType,
        platform: Platform,
        registration_kind: String,
    },

    /// ImportData schema serialization failed.
    #[error(
        code = "IMPORT_SCHEMA_SERIALIZATION_FAILED",
        message = "Failed to serialize ImportData schema",
        retryable = "false",
        internal = "true"
    )]
    ImportSchemaSerializationFailed,
}

pub type Result<T> = alien_error::Result<T, ErrorData>;