2020-12-09 10:11:38 -08:00
// Copyright (c) HashiCorp, Inc.
2021-11-10 06:47:21 -05:00
// SPDX-License-Identifier: BUSL-1.1
2023-02-02 17:15:17 -08:00
2020-11-04 14:42:20 -05:00
package errors
// Code specifies a code for the error.
type Code uint32
// String will return the Code's Info.Message
func ( c Code ) String () string {
return c . Info (). Message
}
// Info will look up the Code's Info. If the Info is not found, it will return
// Info for an Unknown Code.
func ( c Code ) Info () Info {
if info , ok := errorCodeInfo [ c ]; ok {
return info
}
return errorCodeInfo [ Unknown ]
}
const (
Unknown Code = 0 // Unknown will be equal to a zero value for Codes
// General function errors are reserved Codes 100-999
2022-08-12 11:08:25 -04:00
InvalidParameter Code = 100 // InvalidParameter represents an invalid parameter for an operation.
InvalidAddress Code = 101 // InvalidAddress represents an invalid host address for an operation
InvalidPublicId Code = 102 // InvalidPublicId represents an invalid public Id for an operation
2023-05-24 04:28:14 -04:00
InvalidFieldMask Code = 103 // InvalidFieldMask represents an invalid field mask for an operation
2022-08-12 11:08:25 -04:00
EmptyFieldMask Code = 104 // EmptyFieldMask represents an empty field mask for an operation
KeyNotFound Code = 105 // KeyNotFound represents that a key/version was not found in the KMS
TicketAlreadyRedeemed Code = 106 // TicketAlreadyRedeemed represents that the ticket version has already been redeemed
TicketNotFound Code = 107 // TicketNotFound represents that the ticket was not found
Io Code = 108 // Io represents that an io error occurred in an underlying call (i.e binary.Write)
InvalidTimeStamp Code = 109 // InvalidTimeStamp represents an invalid time stamp for an operation
SessionNotFound Code = 110 // SessionNotFound represents that the session was not found
InvalidSessionState Code = 111 // InvalidSessionState represents that the session was in an invalid state
TokenMismatch Code = 112 // TokenMismatch represents that there was a token mismatch
TooShort Code = 113 // TooShort represents an error that means the provided input is not meeting minimum length requirements
AccountAlreadyAssociated Code = 114 // AccountAlreadyAssociated represents an attempt to associate an account failed since it was already associated.
InvalidJobRunState Code = 115 // InvalidJobRunState represents that a JobRun was in an invalid state
InvalidDynamicCredential Code = 116 // InvalidDynamicCredential represents that a dynamic credential for a session was in an invalid state
JobAlreadyRunning Code = 117 // JobAlreadyRunning represents that a Job is already running when an attempt to run again was made
SubtypeAlreadyRegistered Code = 118 // SubtypeAlreadyRegistered represents that a value has already been registered in the subtype registry system.
2025-08-28 12:30:41 -05:00
NoPathFound Code = 119 // NoPathFound represents an error when no path is found to a worker
WorkerNotFound Code = 120 // WorkerNotFound represents an error when a worker is not found in the graph of downstream workers
CycleFound Code = 121 // CycleFound represents an error when a cycle is found between a parent and child worker
WorkerConnNotFound Code = 122 // WorkerConnNotFound represents an error when a connection to a worker is not found
KmsWorkerUnsupportedOperation Code = 123 // KmsWorkerUnsupportedOperation represents an error when a KMS worker is not supported for an operation
2023-03-28 09:39:28 -07:00
2022-10-04 11:07:50 -07:00
// Note: Currently unused in OSS
2025-08-28 12:30:41 -05:00
RetryLimitExceeded Code = 124 // RetryLimitExceeded represents an error when a retry limit is exceeded
2022-10-04 11:07:50 -07:00
// Note: Currently unused in OSS
2025-08-28 12:30:41 -05:00
QueueIsFull Code = 125 // QueueIsFull results in attempting to add an item to a queue which is full
2020-11-04 14:42:20 -05:00
2023-03-28 09:39:28 -07:00
// Note: Storage errors are currently unused in OSS
2025-08-28 12:30:41 -05:00
StorageFileClosed Code = 126 // StorageFileClose represents an error when a file has been closed and a read/write operation is attempted on it
StorageContainerClosed Code = 127 // StorageContainerClosed represents an error when a container has been closed and a I/O operation is attempted on it
StorageFileReadOnly Code = 128 // StorageFileReadOnly represents an error when a file is readonly and a write operation is attempted on it
StorageFileWriteOnly Code = 129 // StorageFileWriteOnly represents an error when a file is write only and a read operation is attempted on it
StorageFileAlreadyExists Code = 130 // StorageFileAlreadyExists represents an error when a file already exists during an attempt to create it
StorageContainerReadOnly Code = 131 // StorageContainerReadOnly represents an error when a container is readonly and a write operation is attempted on it
StorageContainerWriteOnly Code = 132 // StorageContainerWriteOnly represents an error when a container is write only and a read operation is attempted on it
2023-03-28 09:39:28 -07:00
2025-08-28 12:30:41 -05:00
WorkerNotFoundForRequest Code = 133 // WorkerNotFoundForRequest represents an error when no appropriate worker is found which meets the conditions required to handle a request
Closed Code = 134 // Closed represents an error when an operation cannot be completed because the thing being operated on is closed
ChecksumMismatch Code = 135 // ChecksumMismatch represents an error when a checksum is mismatched
InvalidListToken Code = 136 // InvalidListToken represents an error where the provided list token is invalid
Paused Code = 137 // Paused represents an error when an operation cannot be completed because the thing being operated on is paused
2023-10-27 14:39:53 -07:00
2021-04-08 20:54:32 -04:00
AuthAttemptExpired Code = 198 // AuthAttemptExpired represents an expired authentication attempt
AuthMethodInactive Code = 199 // AuthMethodInactive represents an error that means the auth method is not active.
2020-12-21 10:07:34 -08:00
// PasswordTooShort results from attempting to set a password which is to short.
PasswordTooShort Code = 200
// PasswordUnsupportedConfiguration results from attempting to perform an
// operation that sets a password configuration to an unsupported type.
PasswordUnsupportedConfiguration Code = 201
// PasswordInvalidConfiguration results from attempting to perform an
// operation that sets a valid password configuration with invalid settings.
PasswordInvalidConfiguration Code = 202
// PasswordsEqual is returned from ChangePassword when the old and
// new passwords are equal.
PasswordsEqual Code = 203
2021-01-12 08:50:19 -08:00
Encrypt Code = 300 // Encrypt represents an error occurred during the underlying encryption process
Decrypt Code = 301 // Decrypt represents an error occurred during the underlying decryption process
2021-01-13 15:50:07 -08:00
Encode Code = 302 // Encode represents an error occurred during the underlying encoding/marshaling process
Decode Code = 303 // Decode represents an error occurred during the underlying decoding/unmarshaling process
2021-02-03 16:25:56 -08:00
GenKey Code = 304 // GenKey represents an error occurred during the underlying key generation process
GenCert Code = 305 // GenCert represents an error occurred during the underlying certificate generation process
2023-03-18 15:52:50 -04:00
Sign Code = 306 // Sign represents an error occurred during the underlying signing process
Verify Code = 307 // Verify represents an error occurred during the underlying verification process
2021-01-12 08:50:19 -08:00
2021-10-19 17:21:41 -04:00
// General system errors are reserved Codes 400-599 and align with http
// client and server error codes
Unauthorized Code = 401 // Unauthorized represents the operation is unauthorized
Forbidden Code = 403 // Forbidden represents the operation is forbidden
2023-03-28 14:24:05 -07:00
NotFound Code = 404 // NotFound represents an operation which is unable to find the requested item.
2022-12-06 12:33:28 -08:00
Conflict Code = 409 // Conflict represents the operation failed due to failed pre-condition or was aborted.
2021-10-19 17:21:41 -04:00
Internal Code = 500 // InternalError represents the system encountered an unexpected condition.
2021-03-20 06:52:47 -04:00
2020-12-09 10:11:38 -08:00
// DB errors are reserved Codes from 1000-1999
2020-11-04 14:42:20 -05:00
CheckConstraint Code = 1000 // CheckConstraint represents a check constraint error
NotNull Code = 1001 // NotNull represents a value must not be null error
NotUnique Code = 1002 // NotUnique represents a value must be unique error
2020-12-09 10:11:38 -08:00
NotSpecificIntegrity Code = 1003 // NotSpecificIntegrity represents an integrity error that has no specific domain error code
2021-01-19 10:40:41 -07:00
MissingTable Code = 1004 // MissingTable represents an undefined table error
2020-11-04 14:42:20 -05:00
RecordNotFound Code = 1100 // RecordNotFound represents that a record/row was not found matching the criteria
MultipleRecords Code = 1101 // MultipleRecords represents that multiple records/rows were found matching the criteria
2020-12-21 10:07:34 -08:00
ColumnNotFound Code = 1102 // ColumnNotFound represent that a column was not found in the underlying db
MaxRetries Code = 1103 // MaxRetries represent that a db Tx hit max retires allowed
Exception Code = 1104 // Exception represent that an underlying db exception was raised
2021-04-08 20:54:32 -04:00
VersionMismatch Code = 1105 // VersionMismatch represents the update version and the db version for an entry do not match.
2021-06-01 14:18:10 -05:00
// GracefullyAborted means we intended to abort a transaction but the
// enclosing function should not treat it as an error; we aborted for
// reasons related to the state of the DDL and/or inputs (such as we're
// already in the right state and don't want to end up writing oplogs).
GracefullyAborted Code = 1106
2021-10-28 10:09:43 -04:00
// UnexpectedRowsAffected indicates that an action expected to operate on a
// specific number of records returned a different count, e.g. if you
// expected to delete three items and only one was deleted.
UnexpectedRowsAffected Code = 1107
2023-04-06 11:36:21 -07:00
// ImmutableColumn is used when an operation attempted to mutate an immutable column.
ImmutableColumn Code = 1108
2024-04-06 13:48:47 -07:00
// InvalidTextRepresentation represents a value does not have the correct text representation.
InvalidTextRepresentation Code = 1109
2021-01-19 10:40:41 -07:00
2021-04-07 14:50:00 -04:00
// Migration setup errors are codes 2000-2999
2021-01-19 10:40:41 -07:00
MigrationIntegrity Code = 2000 // MigrationIntegrity represents an error with the generated migration related code
MigrationLock Code = 2001 // MigrationLock represents an error related to locking of the DB
2021-04-07 14:50:00 -04:00
// External system errors are reserved codes 3000-3999
2023-05-11 21:38:26 -07:00
Unavailable Code = 3000 // Unavailable represents that an external system is unavailable
ExternalPlugin Code = 3001 // ExternalPlugin represent an error that occurred on a plugin external to Boundary
2021-04-29 14:47:13 -07:00
2021-06-22 22:26:26 -04:00
// Vault specific errors
VaultTokenNotOrphan Code = 3010 // VaultTokenNotOrphan represents an error for a Vault token that is not an orphan token
VaultTokenNotPeriodic Code = 3011 // VaultTokenNotPeriodic represents an error for a Vault token that is not a periodic token
VaultTokenNotRenewable Code = 3012 // VaultTokenNotRenewable represents an error for a Vault token that is not renewable
VaultTokenMissingCapabilities Code = 3013 // VaultTokenMissingCapabilities represents an error for a Vault token that is missing capabilities
VaultCredentialRequest Code = 3014 // VaultCredentialRequest represents an error returned from Vault when retrieving a credential
2021-12-15 15:52:28 -08:00
VaultEmptySecret Code = 3015 // VaultEmptySecret represents a empty secret was returned from Vault without error
2021-10-11 16:16:02 -04:00
VaultInvalidMappingOverride Code = 3016 // VaultInvalidMappingOverride represents an error returned when a credential mapping is unknown or does not match a credential type
2021-11-10 06:47:21 -05:00
VaultInvalidCredentialMapping Code = 3017 // VaultInvalidCredentialMapping represents an error returned when a Vault secret failed to be mapped to a specific credential type
2021-06-22 22:26:26 -04:00
2021-04-29 14:47:13 -07:00
// OIDC authentication provided errors
OidcProviderCallbackError Code = 4000 // OidcProviderCallbackError represents an error that is passed by the OIDC provider to the callback endpoint
2023-11-01 14:19:09 +00:00
// Configuration error codes
InvalidConfiguration Code = 5000 // InvalidConfiguration represents an error with the configuration file.
2020-11-04 14:42:20 -05:00
)