Skip to content

Commit bd4dd98

Browse files
RyanDerrlouisruch
andauthored
Conflicting Error Code Bump (#6002)
* Bump up the error code for InvalidListToken such that it does not conflict with the error code Paused * chore: reorder the errors and give 136 to InvalidListToken over Pausedx * chore(errors): Add missing tests and err info --------- Co-authored-by: Louis Ruch <[email protected]>
1 parent 39d8d96 commit bd4dd98

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

internal/errors/code.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,31 @@ const (
4343
InvalidDynamicCredential Code = 116 // InvalidDynamicCredential represents that a dynamic credential for a session was in an invalid state
4444
JobAlreadyRunning Code = 117 // JobAlreadyRunning represents that a Job is already running when an attempt to run again was made
4545
SubtypeAlreadyRegistered Code = 118 // SubtypeAlreadyRegistered represents that a value has already been registered in the subtype registry system.
46-
NoPathFound = 119 // NoPathFound represents an error when no path is found to a worker
47-
WorkerNotFound = 120 // WorkerNotFound represents an error when a worker is not found in the graph of downstream workers
48-
CycleFound = 121 // CycleFound represents an error when a cycle is found between a parent and child worker
49-
WorkerConnNotFound = 122 // WorkerConnNotFound represents an error when a connection to a worker is not found
50-
KmsWorkerUnsupportedOperation = 123 // KmsWorkerUnsupportedOperation represents an error when a KMS worker is not supported for an operation
46+
NoPathFound Code = 119 // NoPathFound represents an error when no path is found to a worker
47+
WorkerNotFound Code = 120 // WorkerNotFound represents an error when a worker is not found in the graph of downstream workers
48+
CycleFound Code = 121 // CycleFound represents an error when a cycle is found between a parent and child worker
49+
WorkerConnNotFound Code = 122 // WorkerConnNotFound represents an error when a connection to a worker is not found
50+
KmsWorkerUnsupportedOperation Code = 123 // KmsWorkerUnsupportedOperation represents an error when a KMS worker is not supported for an operation
5151

5252
// Note: Currently unused in OSS
53-
RetryLimitExceeded = 124 // RetryLimitExceeded represents an error when a retry limit is exceeded
53+
RetryLimitExceeded Code = 124 // RetryLimitExceeded represents an error when a retry limit is exceeded
5454
// Note: Currently unused in OSS
55-
QueueIsFull = 125 // QueueIsFull results in attempting to add an item to a queue which is full
55+
QueueIsFull Code = 125 // QueueIsFull results in attempting to add an item to a queue which is full
5656

5757
// Note: Storage errors are currently unused in OSS
58-
StorageFileClosed = 126 // StorageFileClose represents an error when a file has been closed and a read/write operation is attempted on it
59-
StorageContainerClosed = 127 // StorageContainerClosed represents an error when a container has been closed and a I/O operation is attempted on it
60-
StorageFileReadOnly = 128 // StorageFileReadOnly represents an error when a file is readonly and a write operation is attempted on it
61-
StorageFileWriteOnly = 129 // StorageFileWriteOnly represents an error when a file is write only and a read operation is attempted on it
62-
StorageFileAlreadyExists = 130 // StorageFileAlreadyExists represents an error when a file already exists during an attempt to create it
63-
StorageContainerReadOnly = 131 // StorageContainerReadOnly represents an error when a container is readonly and a write operation is attempted on it
64-
StorageContainerWriteOnly = 132 // StorageContainerWriteOnly represents an error when a container is write only and a read operation is attempted on it
65-
66-
WorkerNotFoundForRequest = 133 // WorkerNotFoundForRequest represents an error when no appropriate worker is found which meets the conditions required to handle a request
67-
Closed = 134 // Closed represents an error when an operation cannot be completed because the thing being operated on is closed
68-
ChecksumMismatch = 135 // ChecksumMismatch represents an error when a checksum is mismatched
69-
Paused = 136 // Paused represents an error when an operation cannot be completed because the thing being operated on is paused
70-
71-
InvalidListToken Code = 136 // InvalidListToken represents an error where the provided list token is invalid
58+
StorageFileClosed Code = 126 // StorageFileClose represents an error when a file has been closed and a read/write operation is attempted on it
59+
StorageContainerClosed Code = 127 // StorageContainerClosed represents an error when a container has been closed and a I/O operation is attempted on it
60+
StorageFileReadOnly Code = 128 // StorageFileReadOnly represents an error when a file is readonly and a write operation is attempted on it
61+
StorageFileWriteOnly Code = 129 // StorageFileWriteOnly represents an error when a file is write only and a read operation is attempted on it
62+
StorageFileAlreadyExists Code = 130 // StorageFileAlreadyExists represents an error when a file already exists during an attempt to create it
63+
StorageContainerReadOnly Code = 131 // StorageContainerReadOnly represents an error when a container is readonly and a write operation is attempted on it
64+
StorageContainerWriteOnly Code = 132 // StorageContainerWriteOnly represents an error when a container is write only and a read operation is attempted on it
65+
66+
WorkerNotFoundForRequest Code = 133 // WorkerNotFoundForRequest represents an error when no appropriate worker is found which meets the conditions required to handle a request
67+
Closed Code = 134 // Closed represents an error when an operation cannot be completed because the thing being operated on is closed
68+
ChecksumMismatch Code = 135 // ChecksumMismatch represents an error when a checksum is mismatched
69+
InvalidListToken Code = 136 // InvalidListToken represents an error where the provided list token is invalid
70+
Paused Code = 137 // Paused represents an error when an operation cannot be completed because the thing being operated on is paused
7271

7372
AuthAttemptExpired Code = 198 // AuthAttemptExpired represents an expired authentication attempt
7473
AuthMethodInactive Code = 199 // AuthMethodInactive represents an error that means the auth method is not active.

internal/errors/code_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ func TestCode_Both_String_Info(t *testing.T) {
300300
c: VaultInvalidCredentialMapping,
301301
want: VaultInvalidCredentialMapping,
302302
},
303+
{
304+
name: "VaultTokenMissingCapabilities",
305+
c: VaultTokenMissingCapabilities,
306+
want: VaultTokenMissingCapabilities,
307+
},
303308
{
304309
name: "OidcProviderCallbackError",
305310
c: OidcProviderCallbackError,
@@ -425,6 +430,36 @@ func TestCode_Both_String_Info(t *testing.T) {
425430
c: InvalidTextRepresentation,
426431
want: InvalidTextRepresentation,
427432
},
433+
{
434+
name: "Sign",
435+
c: Sign,
436+
want: Sign,
437+
},
438+
{
439+
name: "Verify",
440+
c: Verify,
441+
want: Verify,
442+
},
443+
{
444+
name: "Unauthorized",
445+
c: Unauthorized,
446+
want: Unauthorized,
447+
},
448+
{
449+
name: "Conflict",
450+
c: Conflict,
451+
want: Conflict,
452+
},
453+
{
454+
name: "Paused",
455+
c: Paused,
456+
want: Paused,
457+
},
458+
{
459+
name: "ImmutableColumn",
460+
c: ImmutableColumn,
461+
want: ImmutableColumn,
462+
},
428463
}
429464
for _, tt := range tests {
430465
t.Run(tt.name, func(t *testing.T) {

internal/errors/info.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ var errorCodeInfo = map[Code]Info{
267267
Message: "purposefully aborted without error",
268268
Kind: Other,
269269
},
270+
ImmutableColumn: {
271+
Message: "immutable column",
272+
Kind: Integrity,
273+
},
270274
UnexpectedRowsAffected: {
271275
Message: "unexpected number of rows affected",
272276
Kind: Integrity,
@@ -339,6 +343,10 @@ var errorCodeInfo = map[Code]Info{
339343
Message: "closed",
340344
Kind: State,
341345
},
346+
Paused: {
347+
Message: "paused",
348+
Kind: State,
349+
},
342350
ExternalPlugin: {
343351
Message: "plugin error",
344352
Kind: External,

0 commit comments

Comments
 (0)