Skip to content

Instantly share code, notes, and snippets.

@rluvaton
Last active October 23, 2023 06:41
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save rluvaton/a97a8da46ab6541a3e5702e83b9d357b to your computer and use it in GitHub Desktop.
Save rluvaton/a97a8da46ab6541a3e5702e83b9d357b to your computer and use it in GitHub Desktop.
Mongo Error Code #mongo #ts
export enum MongoErrorCode {
OK = 0,
InternalError = 1,
BadValue = 2,
OBSOLETE_DuplicateKey = 3,
NoSuchKey = 4,
GraphContainsCycle = 5,
HostUnreachable = 6,// Categories: NetworkError, RetriableError
HostNotFound = 7,// Categories: NetworkError, RetriableError
UnknownError = 8,
FailedToParse = 9,
CannotMutateObject = 10,
UserNotFound = 11,
UnsupportedFormat = 12,
Unauthorized = 13,
TypeMismatch = 14,
Overflow = 15,// Categories: ValidationError
InvalidLength = 16,
ProtocolError = 17,
AuthenticationFailed = 18,
CannotReuseObject = 19,
IllegalOperation = 20,
EmptyArrayOperation = 21,
InvalidBSON = 22,// Categories: ValidationError
AlreadyInitialized = 23,
LockTimeout = 24,// Categories: Interruption
RemoteValidationError = 25,
NamespaceNotFound = 26,
IndexNotFound = 27,
PathNotViable = 28,
NonExistentPath = 29,
InvalidPath = 30,
RoleNotFound = 31,
RolesNotRelated = 32,
PrivilegeNotFound = 33,
CannotBackfillArray = 34,
UserModificationFailed = 35,
RemoteChangeDetected = 36,
FileRenameFailed = 37,
FileNotOpen = 38,
FileStreamFailed = 39,
ConflictingUpdateOperators = 40,
FileAlreadyOpen = 41,
LogWriteFailed = 42,
CursorNotFound = 43,// Categories: CursorInvalidatedError
UserDataInconsistent = 45,
LockBusy = 46,
NoMatchingDocument = 47,
NamespaceExists = 48,
InvalidRoleModification = 49,
MaxTimeMSExpired = 50,// Categories: Interruption, ExceededTimeLimitError
ManualInterventionRequired = 51,
DollarPrefixedFieldName = 52,
InvalidIdField = 53,
NotSingleValueField = 54,
InvalidDBRef = 55,
EmptyFieldName = 56,
DottedFieldName = 57,
RoleModificationFailed = 58,
CommandNotFound = 59,
OBSOLETE_DatabaseNotFound = 60,
ShardKeyNotFound = 61,
OplogOperationUnsupported = 62,
OBSOLETE_StaleShardVersion = 63,
WriteConcernFailed = 64,// Categories: WriteConcernError
MultipleErrorsOccurred = 65,// extra: MultipleErrorsOccurredInfo
ImmutableField = 66,
CannotCreateIndex = 67,
IndexAlreadyExists = 68,
AuthSchemaIncompatible = 69,
ShardNotFound = 70,
ReplicaSetNotFound = 71,
InvalidOptions = 72,
InvalidNamespace = 73,
NodeNotFound = 74,
WriteConcernLegacyOK = 75,// Categories: WriteConcernError
NoReplicationEnabled = 76,
OperationIncomplete = 77,
CommandResultSchemaViolation = 78,
UnknownReplWriteConcern = 79,// Categories: WriteConcernError
RoleDataInconsistent = 80,
NoMatchParseContext = 81,
NoProgressMade = 82,
RemoteResultsUnavailable = 83,
OBSOLETE_DuplicateKeyValue = 84,
IndexOptionsConflict = 85,
IndexKeySpecsConflict = 86,
CannotSplit = 87,
OBSOLETE_SplitFailed = 88,
NetworkTimeout = 89,// Categories: NetworkError, RetriableError, NetworkTimeoutError
CallbackCanceled = 90,// Categories: CancellationError
ShutdownInProgress = 91,// Categories: ShutdownError, CancellationError, RetriableError | extra: ShutdownInProgressQuiesceInfo
SecondaryAheadOfPrimary = 92,
InvalidReplicaSetConfig = 93,
NotYetInitialized = 94,
NotSecondary = 95,
OperationFailed = 96,// Categories: CursorInvalidatedError
NoProjectionFound = 97,
DBPathInUse = 98,
UnsatisfiableWriteConcern = 100,// Categories: WriteConcernError
OutdatedClient = 101,
IncompatibleAuditMetadata = 102,
NewReplicaSetConfigurationIncompatible = 103,
NodeNotElectable = 104,
IncompatibleShardingMetadata = 105,
DistributedClockSkewed = 106,
LockFailed = 107,
InconsistentReplicaSetNames = 108,
ConfigurationInProgress = 109,
CannotInitializeNodeWithData = 110,
NotExactValueField = 111,
WriteConflict = 112,
InitialSyncFailure = 113,
InitialSyncOplogSourceMissing = 114,
CommandNotSupported = 115,
DocTooLargeForCapped = 116,
ConflictingOperationInProgress = 117,
NamespaceNotSharded = 118,
InvalidSyncSource = 119,
OplogStartMissing = 120,
DocumentValidationFailure = 121,// extra: doc_validation_error::DocumentValidationFailureInfo
OBSOLETE_ReadAfterOptimeTimeout = 122,
NotAReplicaSet = 123,
IncompatibleElectionProtocol = 124,
CommandFailed = 125,
RPCProtocolNegotiationFailed = 126,
UnrecoverableRollbackError = 127,
LockNotFound = 128,
LockStateChangeFailed = 129,
SymbolNotFound = 130,
OBSOLETE_ConfigServersInconsistent = 132,
FailedToSatisfyReadPreference = 133,
ReadConcernMajorityNotAvailableYet = 134,// Categories: RetriableError
StaleTerm = 135,
CappedPositionLost = 136,
IncompatibleShardingConfigVersion = 137,
RemoteOplogStale = 138,
JSInterpreterFailure = 139,
InvalidSSLConfiguration = 140,
SSLHandshakeFailed = 141,
JSUncatchableError = 142,
CursorInUse = 143,
IncompatibleCatalogManager = 144,
PooledConnectionsDropped = 145,
ExceededMemoryLimit = 146,
ZLibError = 147,
ReadConcernMajorityNotEnabled = 148,// Categories: VoteAbortError
NoConfigPrimary = 149,
StaleEpoch = 150,// Categories: StaleShardVersionError, NeedRetargettingError | extra: StaleEpochInfo
OperationCannotBeBatched = 151,
OplogOutOfOrder = 152,
ChunkTooBig = 153,
InconsistentShardIdentity = 154,
CannotApplyOplogWhilePrimary = 155,
OBSOLETE_NeedsDocumentMove = 156,
CanRepairToDowngrade = 157,
MustUpgrade = 158,
DurationOverflow = 159,
MaxStalenessOutOfRange = 160,
IncompatibleCollationVersion = 161,
CollectionIsEmpty = 162,
ZoneStillInUse = 163,
InitialSyncActive = 164,
ViewDepthLimitExceeded = 165,
CommandNotSupportedOnView = 166,
OptionNotSupportedOnView = 167,
InvalidPipelineOperator = 168,
CommandOnShardedViewNotSupportedOnMongod = 169,// extra: ResolvedView
TooManyMatchingDocuments = 170,
CannotIndexParallelArrays = 171,
TransportSessionClosed = 172,
TransportSessionNotFound = 173,
TransportSessionUnknown = 174,
QueryPlanKilled = 175,// Categories: CursorInvalidatedError
FileOpenFailed = 176,
ZoneNotFound = 177,
RangeOverlapConflict = 178,
WindowsPdhError = 179,
BadPerfCounterPath = 180,
AmbiguousIndexKeyPattern = 181,
InvalidViewDefinition = 182,
ClientMetadataMissingField = 183,
ClientMetadataAppNameTooLarge = 184,
ClientMetadataDocumentTooLarge = 185,
ClientMetadataCannotBeMutated = 186,
LinearizableReadConcernError = 187,
IncompatibleServerVersion = 188,
PrimarySteppedDown = 189,// Categories: NotPrimaryError, RetriableError
MasterSlaveConnectionFailure = 190,
OBSOLETE_BalancerLostDistributedLock = 191,
FailPointEnabled = 192,
NoShardingEnabled = 193,
BalancerInterrupted = 194,
ViewPipelineMaxSizeExceeded = 195,
InvalidIndexSpecificationOption = 197,
OBSOLETE_ReceivedOpReplyMessage = 198,
ReplicaSetMonitorRemoved = 199,
ChunkRangeCleanupPending = 200,
CannotBuildIndexKeys = 201,
NetworkInterfaceExceededTimeLimit = 202,// Categories: ExceededTimeLimitError, NetworkTimeoutError
ShardingStateNotInitialized = 203,
TimeProofMismatch = 204,
ClusterTimeFailsRateLimiter = 205,
NoSuchSession = 206,
InvalidUUID = 207,
TooManyLocks = 208,
StaleClusterTime = 209,
CannotVerifyAndSignLogicalTime = 210,
KeyNotFound = 211,
IncompatibleRollbackAlgorithm = 212,
DuplicateSession = 213,
AuthenticationRestrictionUnmet = 214,
DatabaseDropPending = 215,
ElectionInProgress = 216,
IncompleteTransactionHistory = 217,
UpdateOperationFailed = 218,
FTDCPathNotSet = 219,
FTDCPathAlreadySet = 220,
IndexModified = 221,
CloseChangeStream = 222,
IllegalOpMsgFlag = 223,// Categories: ConnectionFatalMessageParseError
QueryFeatureNotAllowed = 224,
TransactionTooOld = 225,// Categories: VoteAbortError
AtomicityFailure = 226,
CannotImplicitlyCreateCollection = 227,// extra: CannotImplicitlyCreateCollectionInfo
SessionTransferIncomplete = 228,
MustDowngrade = 229,
DNSHostNotFound = 230,
DNSProtocolError = 231,
MaxSubPipelineDepthExceeded = 232,
TooManyDocumentSequences = 233,// Categories: ConnectionFatalMessageParseError
RetryChangeStream = 234,
InternalErrorNotSupported = 235,
ForTestingErrorExtraInfo = 236,// extra: ErrorExtraInfoExample
CursorKilled = 237,// Categories: Interruption, CursorInvalidatedError
NotImplemented = 238,
SnapshotTooOld = 239,// Categories: SnapshotError
DNSRecordTypeMismatch = 240,
ConversionFailure = 241,
CannotCreateCollection = 242,
IncompatibleWithUpgradedServer = 243,
NOT_YET_AVAILABLE_TransactionAborted = 244,
BrokenPromise = 245,
SnapshotUnavailable = 246,// Categories: SnapshotError
ProducerConsumerQueueBatchTooLarge = 247,
ProducerConsumerQueueEndClosed = 248,
StaleDbVersion = 249,// extra: StaleDbRoutingVersion
StaleChunkHistory = 250,// Categories: SnapshotError
NoSuchTransaction = 251,// Categories: VoteAbortError
ReentrancyNotAllowed = 252,
FreeMonHttpInFlight = 253,
FreeMonHttpTemporaryFailure = 254,
FreeMonHttpPermanentFailure = 255,
TransactionCommitted = 256,
TransactionTooLarge = 257,
UnknownFeatureCompatibilityVersion = 258,
KeyedExecutorRetry = 259,
InvalidResumeToken = 260,
TooManyLogicalSessions = 261,
ExceededTimeLimit = 262,// Categories: Interruption, ExceededTimeLimitError, RetriableError
OperationNotSupportedInTransaction = 263,// Categories: VoteAbortError
TooManyFilesOpen = 264,
OrphanedRangeCleanUpFailed = 265,
FailPointSetFailed = 266,
PreparedTransactionInProgress = 267,
CannotBackup = 268,
DataModifiedByRepair = 269,
RepairedReplicaSetNode = 270,
JSInterpreterFailureWithStack = 271,// extra: JSExceptionInfo
MigrationConflict = 272,// Categories: SnapshotError
ProducerConsumerQueueProducerQueueDepthExceeded = 273,
ProducerConsumerQueueConsumed = 274,
ExchangePassthrough = 275,
IndexBuildAborted = 276,
AlarmAlreadyFulfilled = 277,
UnsatisfiableCommitQuorum = 278,
ClientDisconnect = 279,// Categories: Interruption
ChangeStreamFatalError = 280,// Categories: NonResumableChangeStreamError
TransactionCoordinatorSteppingDown = 281,// Categories: Interruption
TransactionCoordinatorReachedAbortDecision = 282,// Categories: Interruption
WouldChangeOwningShard = 283,// extra: WouldChangeOwningShardInfo
ForTestingErrorExtraInfoWithExtraInfoInNamespace = 284,// extra: nested::twice::NestedErrorExtraInfoExample
IndexBuildAlreadyInProgress = 285,
ChangeStreamHistoryLost = 286,// Categories: NonResumableChangeStreamError
TransactionCoordinatorDeadlineTaskCanceled = 287,// Categories: InternalOnly
ChecksumMismatch = 288,// Categories: ConnectionFatalMessageParseError
WaitForMajorityServiceEarlierOpTimeAvailable = 289,// Categories: InternalOnly
TransactionExceededLifetimeLimitSeconds = 290,// Categories: Interruption, ExceededTimeLimitError
NoQueryExecutionPlans = 291,
QueryExceededMemoryLimitNoDiskUseAllowed = 292,
InvalidSeedList = 293,
InvalidTopologyType = 294,
InvalidHeartBeatFrequency = 295,
TopologySetNameRequired = 296,
HierarchicalAcquisitionLevelViolation = 297,
InvalidServerType = 298,
OCSPCertificateStatusRevoked = 299,
RangeDeletionAbandonedBecauseCollectionWithUUIDDoesNotExist = 300,
DataCorruptionDetected = 301,
OCSPCertificateStatusUnknown = 302,
SplitHorizonChange = 303,// Categories: CloseConnectionError
ShardInvalidatedForTargeting = 304,// extra: ShardInvalidatedForTargetingInfo
ReadThroughCacheLookupCanceled = 306,// Categories: InternalOnly
RangeDeletionAbandonedBecauseTaskDocumentDoesNotExist = 307,
CurrentConfigNotCommittedYet = 308,
ExhaustCommandFinished = 309,
PeriodicJobIsStopped = 310,// Categories: CancellationError
TransactionCoordinatorCanceled = 311,// Categories: InternalOnly
OperationIsKilledAndDelisted = 312,// Categories: CancellationError, InternalOnly
ResumableRangeDeleterDisabled = 313,
ObjectIsBusy = 314,// Categories: CursorInvalidatedError
TooStaleToSyncFromSource = 315,// Categories: InternalOnly
QueryTrialRunCompleted = 316,// Categories: InternalOnly
ConnectionPoolExpired = 317,// Categories: NetworkError, RetriableError, InternalOnly
ForTestingOptionalErrorExtraInfo = 318,// extra: OptionalErrorExtraInfoExample
MovePrimaryInProgress = 319,
TenantMigrationConflict = 320,// Categories: TenantMigrationError, TenantMigrationConflictError | extra: TenantMigrationConflictInfo
TenantMigrationCommitted = 321,// Categories: TenantMigrationError
APIVersionError = 322,// Categories: VersionedAPIError
APIStrictError = 323,// Categories: VersionedAPIError
APIDeprecationError = 324,// Categories: VersionedAPIError
TenantMigrationAborted = 325,// Categories: TenantMigrationError
OplogQueryMinTsMissing = 326,
NoSuchTenantMigration = 327,
TenantMigrationAccessBlockerShuttingDown = 328,// Categories: InternalOnly
TenantMigrationInProgress = 329,
SkipCommandExecution = 330,
FailedToRunWithReplyBuilder = 331,
CannotDowngrade = 332,
ServiceExecutorInShutdown = 333,// Categories: ShutdownError, CancellationError, InternalOnly
MechanismUnavailable = 334,
TenantMigrationForgotten = 335,
TimeseriesBucketCleared = 336,// Categories: InternalOnly
AuthenticationAbandoned = 337,// Categories: InternalOnly
ReshardCollectionInProgress = 338,
NoSuchReshardCollection = 339,
ReshardCollectionCommitted = 340,
ReshardCollectionAborted = 341,
ReshardingCriticalSectionTimeout = 342,
ShardCannotRefreshDueToLocksHeld = 343,// extra: ShardCannotRefreshDueToLocksHeldInfo
AuditingNotEnabled = 344,
RuntimeAuditConfigurationNotEnabled = 345,
ChangeStreamInvalidated = 346,// extra: ChangeStreamInvalidationInfo
APIMismatchError = 347,// Categories: VersionedAPIError, VoteAbortError
ChangeStreamTopologyChange = 348,// extra: ChangeStreamTopologyChangeInfo
KeyPatternShorterThanBound = 349,
ReshardCollectionTruncatedError = 350,
ChangeStreamStartAfterInvalidate = 351,// extra: ChangeStreamStartAfterInvalidateInfo
UnsupportedOpQueryCommand = 352,
NonRetryableTenantMigrationConflict = 353,// Categories: TenantMigrationError, TenantMigrationConflictError | extra: NonRetryableTenantMigrationConflictInfo
LoadBalancerSupportMismatch = 354,// Categories: CloseConnectionError
InterruptedDueToStorageChange = 355,// Categories: Interruption, CancellationError
TxnRetryCounterTooOld = 356,// Categories: VoteAbortError | extra: TxnRetryCounterTooOldInfo
InvalidBSONType = 357,
InternalTransactionNotSupported = 358,// Categories: RetriableError
CannotConvertIndexToUnique = 359,// extra: CannotConvertIndexToUniqueInfo
PlacementVersionRefreshCanceled = 360,// Categories: InternalOnly
CollectionUUIDMismatch = 361,// extra: CollectionUUIDMismatchInfo
FutureAlreadyRetrieved = 362,
RetryableTransactionInProgress = 363,
TemporarilyUnavailable = 365,
WouldChangeOwningShardDeletedNoDocument = 366,
FLECompactionPlaceholder = 367,
FLETransactionAbort = 369,
CannotDropShardKeyIndex = 370,
UserWritesBlocked = 371,
CloseConnectionForShutdownCommand = 372,// Categories: CloseConnectionError, InternalOnly
InternalTransactionsExhaustiveFindHasMore = 373,
TransactionAPIMustRetryTransaction = 374,// Categories: InternalOnly
TransactionAPIMustRetryCommit = 375,// Categories: InternalOnly
ChangeStreamNotEnabled = 376,
FLEMaxTagLimitExceeded = 377,
NonConformantBSON = 378,// Categories: ValidationError
DatabaseMetadataRefreshCanceled = 379,// Categories: InternalOnly
RequestAlreadyFulfilled = 380,
ReshardingCoordinatorServiceConflictingOperationInProgress = 381,// Categories: InternalOnly | extra: ReshardingCoordinatorServiceConflictingOperationInProgressInfo
RemoteCommandExecutionError = 382,// Categories: InternalOnly | extra: AsyncRPCErrorInfo
CollectionIsEmptyLocally = 383,
ConnectionError = 384,// Categories: NetworkError, RetriableError, InternalOnly
ConflictingServerlessOperation = 385,
DuplicateKeyId = 386,
EncounteredFLEPayloadWhileApplyingHmac = 387,
TransactionTooLargeForCache = 388,
LibmongocryptError = 389,
InvalidSignature = 390,
ReauthenticationRequired = 391,
InvalidJWT = 392,
InvalidTenantId = 393,
TruncatedSerialization = 395,
IndexInformationTooLarge = 396,
StreamTerminated = 398,// Categories: CloseConnectionError
CannotUpgrade = 400,
ResumeTenantChangeStream = 401,
ResourceExhausted = 402,// Categories: RetriableError
UnsupportedShardingEventNotification = 403,
SocketException = 9001,// Categories: NetworkError, RetriableError
OBSOLETE_RecvStaleConfig = 9996,
CannotGrowDocumentInCappedNamespace = 10003,
LegacyNotPrimary = 10058,
NotWritablePrimary = 10107,// Categories: NotPrimaryError, RetriableError
BSONObjectTooLarge = 10334,
DuplicateKey = 11000,// extra: DuplicateKeyErrorInfo
InterruptedAtShutdown = 11600,// Categories: Interruption, ShutdownError, CancellationError, RetriableError
Interrupted = 11601,// Categories: Interruption
InterruptedDueToReplStateChange = 11602,// Categories: Interruption, NotPrimaryError, RetriableError
BackgroundOperationInProgressForDatabase = 12586,
BackgroundOperationInProgressForNamespace = 12587,
OBSOLETE_PrepareConfigsFailed = 13104,
MergeStageNoMatchingDocument = 13113,
DatabaseDifferCase = 13297,
StaleConfig = 13388,// Categories: StaleShardVersionError, NeedRetargettingError | extra: StaleConfigInfo
NotPrimaryNoSecondaryOk = 13435,// Categories: NotPrimaryError, RetriableError
NotPrimaryOrSecondary = 13436,// Categories: NotPrimaryError, RetriableError
OutOfDiskSpace = 14031,
OBSOLETE_KeyTooLong = 17280,
NamespaceCannotBeSharded = 28769,
ClientMarkedKilled = 46841,// Categories: Interruption, CancellationError
NotARetryableWriteCommand = 50768,
BackupCursorOpenConflictWithCheckpoint = 50915,// Categories: RetriableError
ConfigServerUnreachable = 56846,
RetryableInternalTransactionNotSupported = 57986,
}
(async () => {
const yaml = require('yaml');
const response = await fetch('https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/base/error_codes.yml');
const data = await response.text();
const {error_codes} = yaml.parse(data);
let enumText = 'export enum MongoErrorCode {\n';
error_codes.forEach((code) => {
const extra = [];
if (code.categories) {
extra.push(`Categories: ${code.categories.join(', ')}`);
}
if (code.extra) {
extra.push(`extra: ${code.extra}`);
}
enumText += ` ${code.name} = ${code.code},${extra.length ? `// ${extra.join(' | ')}` : ''}\n`;
})
enumText += '}';
console.log(enumText);
})().catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment