-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patherrors.py
More file actions
536 lines (338 loc) · 15.7 KB
/
errors.py
File metadata and controls
536 lines (338 loc) · 15.7 KB
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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
from __future__ import annotations
from typing import Any
class TFEError(Exception):
def __init__(
self,
message: str,
*,
status: int | None = None,
errors: list[dict | str] | None = None,
):
super().__init__(message)
self.status = status
self.errors = errors or []
class AuthError(TFEError): ...
class NotFound(TFEError): ...
class RateLimited(TFEError):
def __init__(
self,
message: str,
*,
retry_after: float | None = None,
**kw: Any,
) -> None:
super().__init__(message, **kw)
self.retry_after = retry_after
class ValidationError(TFEError): ...
class ServerError(TFEError): ...
class UnsupportedInCloud(TFEError): ...
class UnsupportedInEnterprise(TFEError): ...
class InvalidValues(TFEError): ...
class RequiredFieldMissing(TFEError): ...
class ErrStateVersionUploadNotSupported(TFEError): ...
# Generic error constants
ERR_UNAUTHORIZED = "unauthorized"
ERR_RESOURCE_NOT_FOUND = "resource not found"
ERR_MISSING_DIRECTORY = "path needs to be an existing directory"
ERR_NAMESPACE_NOT_AUTHORIZED = "namespace not authorized"
# Error message constants
ERR_INVALID_NAME = "invalid value for name"
ERR_REQUIRED_NAME = "name is required"
ERR_INVALID_ORG = "invalid organization name"
ERR_REQUIRED_EMAIL = "email is required"
ERR_INVALID_EMAIL = "invalid email format"
ERR_INVALID_MEMBERSHIP_ID = "invalid value for organization membership ID"
# Registry Module Error Constants
ERR_REQUIRED_PROVIDER = "provider is required"
ERR_INVALID_PROVIDER = "invalid value for provider"
ERR_REQUIRED_VERSION = "version is required"
ERR_INVALID_VERSION = "invalid value for version"
ERR_INVALID_NAMESPACE = "invalid value for namespace"
ERR_REQUIRED_NAMESPACE = "namespace is required"
ERR_INVALID_REGISTRY_NAME = "invalid registry name"
ERR_UNSUPPORTED_BOTH_NAMESPACE_AND_PRIVATE_REGISTRY_NAME = (
"namespace cannot be used with private registry"
)
ERR_REQUIRED_VCS_REPO = "VCS repo is required"
ERR_REQUIRED_BRANCH_WHEN_TESTS_ENABLED = "branch is required when tests are enabled"
ERR_BRANCH_MUST_BE_EMPTY_WHEN_TAGS_ENABLED = (
"branch must be empty when tags are enabled"
)
ERR_AGENT_POOL_NOT_REQUIRED_FOR_REMOTE_EXECUTION = (
"agent pool not required for remote execution"
)
ERR_INVALID_MODULE_ID = "invalid module ID"
# Workspaces
ERR_INVALID_WORKSPACE_ID = "invalid workspace ID"
ERR_INVALID_VARIABLE_ID = "invalid variable ID"
# Configuration Versions
ERR_INVALID_CONFIG_VERSION_ID = "invalid configuration version ID"
ERR_REQUIRED_KEY = "key is required"
ERR_REQUIRED_CATEGORY = "category is required"
# OAuth Client Error Constants
ERR_INVALID_OAUTH_CLIENT_ID = "invalid OAuth client ID"
ERR_REQUIRED_API_URL = "API URL is required"
ERR_REQUIRED_HTTP_URL = "HTTP URL is required"
ERR_REQUIRED_OAUTH_TOKEN = "OAuth token is required"
ERR_REQUIRED_SERVICE_PROVIDER = "service provider is required"
ERR_UNSUPPORTED_PRIVATE_KEY = "private key is not supported for this service provider"
ERR_REQUIRED_PROJECT = "projects are required"
ERR_PROJECT_MIN_LIMIT = "must specify at least one project"
# OAuth Token Error Constants
ERR_INVALID_OAUTH_TOKEN_ID = "invalid OAuth token ID"
# SSH Key Error Constants
ERR_INVALID_SSH_KEY_ID = "invalid SSH key ID"
# Reserved Tag Key Error Constants
ERR_INVALID_RESERVED_TAG_KEY_ID = "invalid reserved tag key ID"
ERR_REQUIRED_TAG_KEY = "tag key is required"
ERR_INVALID_TAG_KEY = "invalid tag key"
class WorkspaceNotFound(NotFound): ...
class WorkspaceNameConflict(ValidationError): ...
class WorkspaceLocked(TFEError): ...
class WorkspaceLockedStateVersionStillPending(TFEError): ...
# Workspace validation errors
class WorkspaceValidationError(ValidationError):
"""Base class for workspace validation errors."""
pass
class InvalidNameError(WorkspaceValidationError):
"""Raised when workspace name is invalid."""
def __init__(self) -> None:
super().__init__("invalid value for name")
class UnsupportedOperationsError(WorkspaceValidationError):
"""Raised when operations is specified with execution mode."""
def __init__(self) -> None:
super().__init__(
"operations is deprecated and cannot be specified when execution mode is used"
)
class RequiredAgentModeError(WorkspaceValidationError):
"""Raised when agent pool ID is specified without agent execution mode."""
def __init__(self) -> None:
super().__init__("specifying an agent pool ID requires 'agent' execution mode")
class RequiredAgentPoolIDError(WorkspaceValidationError):
"""Raised when agent execution mode is specified without agent pool ID."""
def __init__(self) -> None:
super().__init__(
"'agent' execution mode requires an agent pool ID to be specified"
)
class UnsupportedBothTriggerPatternsAndPrefixesError(WorkspaceValidationError):
"""Raised when both trigger patterns and prefixes are specified."""
def __init__(self) -> None:
super().__init__(
'"TriggerPatterns" and "TriggerPrefixes" cannot be populated at the same time'
)
class UnsupportedBothTagsRegexAndTriggerPatternsError(WorkspaceValidationError):
"""Raised when both tags regex and trigger patterns are specified."""
def __init__(self) -> None:
super().__init__(
'"TagsRegex" and "TriggerPatterns" cannot be populated at the same time'
)
class UnsupportedBothTagsRegexAndTriggerPrefixesError(WorkspaceValidationError):
"""Raised when both tags regex and trigger prefixes are specified."""
def __init__(self) -> None:
super().__init__(
'"TagsRegex" and "TriggerPrefixes" cannot be populated at the same time'
)
class UnsupportedBothTagsRegexAndFileTriggersEnabledError(WorkspaceValidationError):
"""Raised when both tags regex and file triggers are enabled."""
def __init__(self) -> None:
super().__init__(
'"TagsRegex" cannot be populated when "FileTriggersEnabled" is true'
)
# Parameter validation errors
class InvalidWorkspaceValueError(WorkspaceValidationError):
"""Raised when workspace name parameter is invalid."""
def __init__(self) -> None:
super().__init__("invalid value for workspace")
class RequiredSSHKeyIDError(WorkspaceValidationError):
"""Raised when SSH key ID parameter is required but not provided."""
def __init__(self) -> None:
super().__init__("SSH key ID is required")
class InvalidSSHKeyIDError(WorkspaceValidationError):
"""Raised when SSH key ID parameter is invalid."""
def __init__(self) -> None:
super().__init__("invalid value for SSH key ID")
class WorkspaceRequiredError(WorkspaceValidationError):
"""Raised when workspace parameter is required but not provided."""
def __init__(self) -> None:
super().__init__("workspace is required")
class WorkspaceMinimumLimitError(WorkspaceValidationError):
"""Raised when at least one workspace is required but not provided."""
def __init__(self) -> None:
super().__init__("must provide at least one workspace")
class MissingTagIdentifierError(WorkspaceValidationError):
"""Raised when tag identifier is missing."""
def __init__(self) -> None:
super().__init__("must specify at least one tag by ID or name")
class MissingTagBindingIdentifierError(WorkspaceValidationError):
"""Raised when tag binding identifier is missing."""
def __init__(self) -> None:
super().__init__("TagBindings are required")
class InvalidOrgError(InvalidValues):
"""Raised when an invalid run task ID is provided."""
def __init__(self, message: str = "invalid value for organization"):
super().__init__(message)
class InvalidWorkspaceIDError(InvalidValues):
"""Raised when an invalid run workspace ID is provided."""
def __init__(self, message: str = "invalid value for workspace ID"):
super().__init__(message)
class RequiredNameError(RequiredFieldMissing):
"""Raised when a required name field is missing."""
def __init__(self, message: str = "name is required"):
super().__init__(message)
class RequiredWorkspaceError(RequiredFieldMissing):
"""Raised when a required workspace field is missing."""
def __init__(self, message: str = "workspace is required"):
super().__init__(message)
# Run Task errors
class InvalidRunTaskIDError(InvalidValues):
"""Raised when an invalid run task ID is provided."""
def __init__(self, message: str = "invalid value for run task ID"):
super().__init__(message)
class InvalidRunTaskNameError(InvalidValues):
"""Raised when an invalid run task name is provided."""
pass
class InvalidRunTaskURLError(InvalidValues):
"""Raised when an invalid run task URL is provided."""
def __init__(self, message: str = "invalid url for run task URL"):
super().__init__(message)
class InvalidRunTaskCategoryError(InvalidValues):
"""Raised when an invalid run task category is provided."""
def __init__(self, message: str = 'category must be "task"'):
super().__init__(message)
class InvalidWorkspaceRunTaskIDError(InvalidValues):
"""Raised when an invalid workspace run task ID is provided."""
def __init__(self, message: str = "invalid value for workspace run task ID"):
super().__init__(message)
# Run Trigger errors
class RequiredRunTriggerListOpsError(RequiredFieldMissing):
"""Raised when required run trigger list options are missing."""
def __init__(self, message: str = "required run trigger list options"):
super().__init__(message)
class RequiredSourceableError(RequiredFieldMissing):
"""Raised when a required sourceable field is missing."""
def __init__(self, message: str = "sourceable is required"):
super().__init__(message)
class InvalidRunTriggerTypeError(InvalidValues):
"""Raised when an invalid run trigger type is provided."""
def __init__(
self,
message: str = 'invalid value or no value for RunTriggerType. It must be either "inbound" or "outbound"',
):
super().__init__(message)
class UnsupportedRunTriggerTypeError(InvalidValues):
"""Raised when an unsupported run trigger type is provided with include params."""
def __init__(
self,
message: str = 'unsupported RunTriggerType. It must be "inbound" when requesting "include" query params',
):
super().__init__(message)
class InvalidRunTriggerIDError(InvalidValues):
"""Raised when an invalid run trigger ID is provided."""
def __init__(self, message: str = "invalid value for run trigger ID"):
super().__init__(message)
# Run errors
class InvalidRunIDError(InvalidValues):
"""Raised when an invalid run ID is provided."""
def __init__(self, message: str = "invalid value for run ID"):
super().__init__(message)
class InvalidQueryRunIDError(InvalidValues):
"""Raised when an invalid query run ID is provided."""
def __init__(self, message: str = "invalid value for query run ID"):
super().__init__(message)
class TerraformVersionValidForPlanOnlyError(ValidationError):
"""Raised when terraform_version is set without plan_only being true."""
def __init__(
self,
message: str = "setting terraform-version is only valid when plan-only is set to true",
):
super().__init__(message)
# Plan errors
class InvalidPlanIDError(InvalidValues):
"""Raised when an invalid plan ID is provided."""
def __init__(self, message: str = "invalid value for plan ID"):
super().__init__(message)
# Apply errors
class InvalidApplyIDError(InvalidValues):
"""Raised when an invalid apply ID is provided."""
def __init__(self, message: str = "invalid value for apply ID"):
super().__init__(message)
# Run Event errors
class InvalidRunEventIDError(InvalidValues):
"""Raised when an invalid run event ID is provided."""
def __init__(self, message: str = "invalid value for run event ID"):
super().__init__(message)
# Policy errors
class InvalidPolicyIDError(InvalidValues):
"""Raised when an invalid policy ID is provided."""
def __init__(self, message: str = "invalid value for policy ID"):
super().__init__(message)
class RequiredQueryError(RequiredFieldMissing):
"""Raised when a required query field is missing."""
def __init__(self, message: str = "query is required"):
super().__init__(message)
class RequiredEnforceError(RequiredFieldMissing):
"""Raised when a required enforce field is missing."""
def __init__(self, message: str = "enforce or enforcement-level is required"):
super().__init__(message)
# Policy Check errors
class InvalidPolicyCheckIDError(InvalidValues):
"""Raised when an invalid policy check ID is provided."""
def __init__(self, message: str = "invalid value for policy check ID"):
super().__init__(message)
# Policy Set errors
class InvalidPolicySetIDError(InvalidValues):
"""Raised when an invalid policy set ID is provided."""
def __init__(self, message: str = "invalid value for policy set ID"):
super().__init__(message)
class RequiredPoliciesError(RequiredFieldMissing):
"""Raised when a required policies field is missing."""
def __init__(self, message: str = "policies are required"):
super().__init__(message)
class InvalidPoliciesError(InvalidValues):
"""Raised when an invalid policies field is provided."""
def __init__(self, message: str = "must provide at least one policy"):
super().__init__(message)
# Policy Evaluation errors
class InvalidTaskStageIDError(InvalidValues):
"""Raised when an invalid task stage ID is provided."""
def __init__(self, message: str = "invalid value for task stage ID"):
super().__init__(message)
class InvalidPolicyEvaluationIDError(InvalidValues):
"""Raised when an invalid policy evaluation ID is provided."""
def __init__(self, message: str = "invalid value for policy evaluation ID"):
super().__init__(message)
# Policy Set Parameter errors
class InvalidParamIDError(InvalidValues):
"""Raised when an invalid policy set parameter ID is provided."""
def __init__(self, message: str = "invalid value for parameter ID"):
super().__init__(message)
class RequiredCategoryError(RequiredFieldMissing):
"""Raised when a required category field is missing."""
def __init__(self, message: str = "category is required"):
super().__init__(message)
class InvalidCategoryError(InvalidValues):
"""Raised when an invalid category field is provided."""
def __init__(self, message: str = "category must be policy-set"):
super().__init__(message)
class RequiredKeyError(RequiredFieldMissing):
"""Raised when a required key field is missing."""
def __init__(self, message: str = "key is required"):
super().__init__(message)
# Policy Set Outcome errors
class InvalidPolicySetOutcomeIDError(InvalidValues):
"""Raised when an invalid policy set outcome ID is provided."""
def __init__(self, message: str = "invalid value for policy set outcome ID"):
super().__init__(message)
# Registry Provider Version errors
class RequiredPrivateRegistryError(RequiredFieldMissing):
"""Raised when a required private registry field is missing."""
def __init__(self, message: str = "only private registry is allowed"):
super().__init__(message)
class InvalidVersionError(InvalidValues):
"""Raised when an invalid version is provided."""
def __init__(self, message: str = "invalid value for version"):
super().__init__(message)
class InvalidKeyIDError(InvalidValues):
"""Raised when an invalid key ID is provided."""
def __init__(self, message: str = "invalid value for key-id"):
super().__init__(message)