1use alien_error::AlienErrorData;
2use serde::{Deserialize, Serialize};
3
4use crate::{Platform, ResourceType};
5
6#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub enum ErrorData {
10 #[error(
12 code = "STACK_INPUT_INVALID",
13 message = "Stack input '{input_id}': {reason}",
14 retryable = "false",
15 internal = "false",
16 http_status_code = 400
17 )]
18 StackInputInvalid { input_id: String, reason: String },
19
20 #[error(
22 code = "STACK_DEFINITION_INVALID",
23 message = "Invalid {field}: {reason}",
24 retryable = "false",
25 internal = "false",
26 http_status_code = 400
27 )]
28 StackDefinitionInvalid {
29 field: String,
31 reason: String,
33 },
34
35 #[error(
37 code = "GCP_FEDERATION_INVALID",
38 message = "Invalid GCP federation field '{field}': {reason}",
39 retryable = "false",
40 internal = "false",
41 http_status_code = 400
42 )]
43 GcpFederationInvalid { field: String, reason: String },
44
45 #[error(
47 code = "SANDBOX_IMAGE_USER_INVALID",
48 message = "Invalid sandbox image USER '{user}': {reason}",
49 retryable = "false",
50 internal = "false",
51 http_status_code = 400
52 )]
53 SandboxImageUserInvalid { user: String, reason: String },
54 #[error(
56 code = "SANDBOX_EGRESS_POLICY_TOO_LARGE",
57 message = "Sandbox egress policy exceeds {limit}",
58 retryable = "false",
59 internal = "false",
60 http_status_code = 400
61 )]
62 SandboxEgressPolicyTooLarge { limit: String },
63
64 #[error(
66 code = "SANDBOX_EGRESS_INVALID",
67 message = "Invalid sandbox egress target '{target}': {reason}",
68 retryable = "false",
69 internal = "false",
70 http_status_code = 400
71 )]
72 SandboxEgressInvalid { target: String, reason: String },
73
74 #[error(
76 code = "SANDBOX_INTERNET_GATEWAY_MISSING",
77 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",
78 retryable = "false",
79 internal = "false"
80 )]
81 SandboxInternetGatewayMissing { sandbox_id: String },
82
83 #[error(
85 code = "CONTAINER_RESOURCE_SELECTION_INVALID",
86 message = "Invalid {dimension} selection for container '{resource_id}': {reason}",
87 retryable = "false",
88 internal = "false",
89 http_status_code = 400
90 )]
91 ContainerResourceSelectionInvalid {
92 resource_id: String,
93 dimension: String,
94 reason: String,
95 },
96 #[error(
99 code = "RENDERED_CHART_REFUSED",
100 message = "{reason}",
101 retryable = "false",
102 internal = "false"
103 )]
104 RenderedChartRefused {
105 reason: String,
107 },
108
109 #[error(
111 code = "GENERIC_ERROR",
112 message = "{message}",
113 retryable = "true",
114 internal = "false"
115 )]
116 GenericError {
117 message: String,
119 },
120
121 #[error(
123 code = "UNEXPECTED_RESOURCE_TYPE",
124 message = "Unexpected resource type for resource '{resource_id}': expected {expected}, but got {actual}",
125 retryable = "false",
126 internal = "false"
127 )]
128 UnexpectedResourceType {
129 resource_id: String,
130 expected: ResourceType,
131 actual: ResourceType,
132 },
133
134 #[error(
136 code = "INVALID_RESOURCE_UPDATE",
137 message = "Resource '{resource_id}' cannot be updated: {reason}",
138 retryable = "false",
139 internal = "false"
140 )]
141 InvalidResourceUpdate { resource_id: String, reason: String },
142
143 #[error(
145 code = "WORKER_TIMEOUT_INVALID",
146 message = "Worker timeoutSeconds must be between 1 and {max_timeout_seconds} seconds, got {timeout_seconds}",
147 retryable = "false",
148 internal = "false",
149 http_status_code = 400
150 )]
151 WorkerTimeoutInvalid {
152 timeout_seconds: u32,
153 max_timeout_seconds: u32,
154 },
155
156 #[error(
158 code = "RESOURCE_HAS_NO_OUTPUTS",
159 message = "Resource '{resource_id}' has no outputs",
160 retryable = "true",
161 internal = "false"
162 )]
163 ResourceHasNoOutputs { resource_id: String },
164
165 #[error(
167 code = "RESOURCE_NOT_FOUND",
168 message = "Resource '{resource_id}' not found in stack state. Available resources: {available_resources:?}",
169 retryable = "false",
170 internal = "false",
171 http_status_code = 404
172 )]
173 ResourceNotFound {
174 resource_id: String,
175 available_resources: Vec<String>,
176 },
177
178 #[error(
180 code = "BINDING_CONFIG_INVALID",
181 message = "Invalid binding configuration for '{binding_name}': {reason}",
182 retryable = "false",
183 internal = "false"
184 )]
185 BindingConfigInvalid {
186 binding_name: String,
187 reason: String,
188 },
189
190 #[error(
192 code = "BINDING_ENV_VAR_MISSING",
193 message = "Missing environment variable '{env_var}' for binding '{binding_name}'",
194 retryable = "false",
195 internal = "false"
196 )]
197 BindingEnvVarMissing {
198 binding_name: String,
199 env_var: String,
200 },
201
202 #[error(
204 code = "BINDING_JSON_PARSE_FAILED",
205 message = "Failed to parse binding JSON for '{binding_name}': {reason}",
206 retryable = "false",
207 internal = "false"
208 )]
209 BindingJsonParseFailed {
210 binding_name: String,
211 reason: String,
212 },
213
214 #[error(
216 code = "UNEXPECTED_RESOURCE_STATUS_COMBINATION",
217 message = "Unexpected resource status combination during {operation}: {resource_statuses:?}",
218 retryable = "false",
219 internal = "true"
220 )]
221 UnexpectedResourceStatusCombination {
222 resource_statuses: Vec<String>,
223 operation: String,
224 },
225
226 #[error(
228 code = "EXTERNAL_BINDING_TYPE_MISMATCH",
229 message = "External binding type mismatch for resource '{resource_id}': expected {expected}, got {actual}",
230 retryable = "false",
231 internal = "false"
232 )]
233 ExternalBindingTypeMismatch {
234 resource_id: String,
235 expected: String,
236 actual: String,
237 },
238
239 #[error(
242 code = "PRESIGNED_REQUEST_EXPIRED",
243 message = "Presigned request for '{path}' expired at {expired_at}",
244 retryable = "false",
245 internal = "false"
246 )]
247 PresignedRequestExpired {
248 path: String,
249 expired_at: chrono::DateTime<chrono::Utc>,
250 },
251
252 #[error(
254 code = "HTTP_REQUEST_FAILED",
255 message = "HTTP {method} request to '{url}' failed",
256 retryable = "true",
257 internal = "false"
258 )]
259 HttpRequestFailed { url: String, method: String },
260
261 #[error(
263 code = "OPERATION_NOT_SUPPORTED",
264 message = "Operation '{operation}' not supported: {reason}",
265 retryable = "false",
266 internal = "false"
267 )]
268 OperationNotSupported { operation: String, reason: String },
269
270 #[error(
272 code = "SETUP_PLACEMENT_UNSUPPORTED",
273 message = "{message}",
274 retryable = "false",
275 internal = "false",
276 http_status_code = 422
277 )]
278 SetupPlacementUnsupported {
279 message: String,
281 resource_type: String,
283 resource_id: String,
285 },
286
287 #[error(
289 code = "LOCAL_FILESYSTEM_ERROR",
290 message = "Local filesystem error for '{path}' during {operation}",
291 retryable = "false",
292 internal = "false"
293 )]
294 LocalFilesystemError { path: String, operation: String },
295
296 #[error(
298 code = "FEATURE_NOT_ENABLED",
299 message = "Feature '{feature}' is not enabled",
300 retryable = "false",
301 internal = "false"
302 )]
303 FeatureNotEnabled { feature: String },
304
305 #[error(
307 code = "AUTOMATIC_SETUP_RESOURCE_UNSUPPORTED",
308 message = "Automatic infrastructure management does not support {resource_type} '{resource_id}' on {platform}; use manual setup",
309 retryable = "false",
310 internal = "false",
311 http_status_code = 400
312 )]
313 AutomaticSetupResourceUnsupported {
314 resource_type: String,
315 resource_id: String,
316 platform: Platform,
317 },
318
319 #[error(
321 code = "SANDBOX_CAPABILITY_UNSUPPORTED",
322 message = "Sandbox capability '{capability}' is not supported on {platform}",
323 retryable = "false",
324 internal = "false",
325 http_status_code = 400
326 )]
327 SandboxCapabilityUnsupported {
328 capability: String,
330 platform: String,
332 },
333
334 #[error(
336 code = "SANDBOX_PLATFORM_UNSUPPORTED",
337 message = "Sandbox is not available on {platform}",
338 retryable = "false",
339 internal = "false",
340 http_status_code = 400
341 )]
342 SandboxPlatformUnsupported {
343 platform: String,
345 },
346
347 #[error(
349 code = "BUNDLE_SIGNATURE_INVALID",
350 message = "Bundle signature invalid: {reason}",
351 retryable = "false",
352 internal = "false",
353 http_status_code = 400
354 )]
355 BundleSignatureInvalid {
356 reason: String,
358 },
359
360 #[error(
362 code = "RELEASE_SIGNING_KEY_INVALID",
363 message = "Release signing key invalid: {reason}",
364 retryable = "false",
365 internal = "false",
366 http_status_code = 400
367 )]
368 ReleaseSigningKeyInvalid {
369 reason: String,
371 },
372
373 #[error(
375 code = "SIGNING_SETTINGS_INVALID",
376 message = "Signing settings invalid: {reason}",
377 retryable = "false",
378 internal = "false",
379 http_status_code = 400
380 )]
381 SigningSettingsInvalid {
382 reason: String,
384 },
385
386 #[error(
388 code = "RELEASE_STATEMENT_INVALID",
389 message = "Release statement invalid: {reason}",
390 retryable = "false",
391 internal = "false",
392 http_status_code = 400
393 )]
394 ReleaseStatementInvalid {
395 reason: String,
397 },
398
399 #[error(
401 code = "SANDBOX_CAPABILITY_REFUSED",
402 message = "Sandbox capability refused: {reason}",
403 retryable = "false",
404 internal = "false",
405 http_status_code = 403
406 )]
407 SandboxCapabilityRefused {
408 reason: String,
410 },
411
412 #[error(
414 code = "SANDBOX_LIMIT_INVALID",
415 message = "Sandbox '{resource_id}' has an invalid {field} limit '{value}': {reason}",
416 retryable = "false",
417 internal = "false",
418 http_status_code = 400
419 )]
420 SandboxLimitInvalid {
421 resource_id: String,
423 field: String,
425 value: String,
427 reason: String,
429 },
430
431 #[error(
434 code = "INVALID_ENVELOPE",
435 message = "Invalid Commands envelope: {message}",
436 retryable = "false",
437 internal = "false"
438 )]
439 InvalidEnvelope {
440 message: String,
441 field: Option<String>,
442 },
443
444 #[error(
447 code = "COMMAND_TOKEN_MISSING",
448 message = "Deployment has command-enabled resource '{resource_id}' but no deployment token to authenticate it: {reason}",
449 retryable = "false",
450 internal = "false"
451 )]
452 CommandTokenMissing { resource_id: String, reason: String },
453
454 #[error(
456 code = "PUBLIC_URL_INVALID",
457 message = "Invalid public URL for resource '{resource_id}': {reason}",
458 retryable = "false",
459 internal = "false",
460 http_status_code = 400
461 )]
462 PublicUrlInvalid { resource_id: String, reason: String },
463
464 #[error(
466 code = "JSON_SERIALIZATION_FAILED",
467 message = "Failed to serialize JSON: {reason}",
468 retryable = "false",
469 internal = "false"
470 )]
471 JsonSerializationFailed { reason: String },
472
473 #[error(
475 code = "JSON_DESERIALIZATION_FAILED",
476 message = "Failed to deserialize JSON: {reason}",
477 retryable = "false",
478 internal = "false"
479 )]
480 JsonDeserializationFailed { reason: String },
481
482 #[error(
484 code = "TEMPLATE_SERIALIZATION_FAILED",
485 message = "Failed to serialize {format} template: {reason}",
486 retryable = "false",
487 internal = "true"
488 )]
489 TemplateSerializationFailed { format: String, reason: String },
490
491 #[error(
493 code = "MANAGEMENT_EXTERNAL_ID_INVALID",
494 message = "Management ExternalId must be 32 to 128 ASCII letters and digits (got {length} characters)",
495 retryable = "false",
496 internal = "false",
497 http_status_code = 400
498 )]
499 ManagementExternalIdInvalid {
500 length: usize,
502 },
503
504 #[error(
507 code = "MANAGING_ROLE_ARN_INVALID",
508 message = "Managing role ARN '{arn}' is not an IAM role ARN (arn:<partition>:iam::<account>:role/<name>)",
509 retryable = "false",
510 internal = "false",
511 http_status_code = 400
512 )]
513 ManagingRoleArnInvalid {
514 arn: String,
516 },
517
518 #[error(
520 code = "IMPORT_DATA_INVALID",
521 message = "Invalid ImportData for resource '{resource_id}' ({resource_type}) on {platform}",
522 retryable = "false",
523 internal = "false",
524 http_status_code = 400
525 )]
526 ImportDataInvalid {
527 resource_id: String,
528 resource_type: ResourceType,
529 platform: Platform,
530 },
531
532 #[error(
534 code = "IMPORT_REGISTRATION_MISSING",
535 message = "Missing {registration_kind} registration for resource type '{resource_type}' on {platform}",
536 retryable = "false",
537 internal = "true"
538 )]
539 ImportRegistrationMissing {
540 resource_type: ResourceType,
541 platform: Platform,
542 registration_kind: String,
543 },
544
545 #[error(
547 code = "IMPORT_SCHEMA_SERIALIZATION_FAILED",
548 message = "Failed to serialize ImportData schema",
549 retryable = "false",
550 internal = "true"
551 )]
552 ImportSchemaSerializationFailed,
553}
554
555pub type Result<T> = alien_error::Result<T, ErrorData>;