github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/cmd/api-errors.go (about)

     1  // Copyright (c) 2015-2023 MinIO, Inc.
     2  //
     3  // This file is part of MinIO Object Storage stack
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package cmd
    19  
    20  import (
    21  	"context"
    22  	"encoding/xml"
    23  	"errors"
    24  	"fmt"
    25  	"net/http"
    26  	"net/url"
    27  	"os"
    28  	"strconv"
    29  	"strings"
    30  
    31  	"github.com/Azure/azure-storage-blob-go/azblob"
    32  	"github.com/minio/minio/internal/ioutil"
    33  	"google.golang.org/api/googleapi"
    34  
    35  	"github.com/minio/madmin-go/v3"
    36  	"github.com/minio/minio-go/v7"
    37  	"github.com/minio/minio-go/v7/pkg/tags"
    38  	"github.com/minio/minio/internal/auth"
    39  	"github.com/minio/minio/internal/bucket/lifecycle"
    40  	"github.com/minio/minio/internal/bucket/replication"
    41  	"github.com/minio/minio/internal/config/dns"
    42  	"github.com/minio/minio/internal/crypto"
    43  	"github.com/minio/minio/internal/kms"
    44  	"github.com/minio/minio/internal/logger"
    45  
    46  	objectlock "github.com/minio/minio/internal/bucket/object/lock"
    47  	"github.com/minio/minio/internal/bucket/versioning"
    48  	levent "github.com/minio/minio/internal/config/lambda/event"
    49  	"github.com/minio/minio/internal/event"
    50  	"github.com/minio/minio/internal/hash"
    51  	"github.com/minio/pkg/v2/policy"
    52  )
    53  
    54  // APIError structure
    55  type APIError struct {
    56  	Code           string
    57  	Description    string
    58  	HTTPStatusCode int
    59  }
    60  
    61  // APIErrorResponse - error response format
    62  type APIErrorResponse struct {
    63  	XMLName    xml.Name `xml:"Error" json:"-"`
    64  	Code       string
    65  	Message    string
    66  	Key        string `xml:"Key,omitempty" json:"Key,omitempty"`
    67  	BucketName string `xml:"BucketName,omitempty" json:"BucketName,omitempty"`
    68  	Resource   string
    69  	Region     string `xml:"Region,omitempty" json:"Region,omitempty"`
    70  	RequestID  string `xml:"RequestId" json:"RequestId"`
    71  	HostID     string `xml:"HostId" json:"HostId"`
    72  }
    73  
    74  // APIErrorCode type of error status.
    75  type APIErrorCode int
    76  
    77  //go:generate stringer -type=APIErrorCode -trimprefix=Err $GOFILE
    78  
    79  // Error codes, non exhaustive list - http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
    80  const (
    81  	ErrNone APIErrorCode = iota
    82  	ErrAccessDenied
    83  	ErrBadDigest
    84  	ErrEntityTooSmall
    85  	ErrEntityTooLarge
    86  	ErrPolicyTooLarge
    87  	ErrIncompleteBody
    88  	ErrInternalError
    89  	ErrInvalidAccessKeyID
    90  	ErrAccessKeyDisabled
    91  	ErrInvalidArgument
    92  	ErrInvalidBucketName
    93  	ErrInvalidDigest
    94  	ErrInvalidRange
    95  	ErrInvalidRangePartNumber
    96  	ErrInvalidCopyPartRange
    97  	ErrInvalidCopyPartRangeSource
    98  	ErrInvalidMaxKeys
    99  	ErrInvalidEncodingMethod
   100  	ErrInvalidMaxUploads
   101  	ErrInvalidMaxParts
   102  	ErrInvalidPartNumberMarker
   103  	ErrInvalidPartNumber
   104  	ErrInvalidRequestBody
   105  	ErrInvalidCopySource
   106  	ErrInvalidMetadataDirective
   107  	ErrInvalidCopyDest
   108  	ErrInvalidPolicyDocument
   109  	ErrInvalidObjectState
   110  	ErrMalformedXML
   111  	ErrMissingContentLength
   112  	ErrMissingContentMD5
   113  	ErrMissingRequestBodyError
   114  	ErrMissingSecurityHeader
   115  	ErrNoSuchBucket
   116  	ErrNoSuchBucketPolicy
   117  	ErrNoSuchBucketLifecycle
   118  	ErrNoSuchLifecycleConfiguration
   119  	ErrInvalidLifecycleWithObjectLock
   120  	ErrNoSuchBucketSSEConfig
   121  	ErrNoSuchCORSConfiguration
   122  	ErrNoSuchWebsiteConfiguration
   123  	ErrReplicationConfigurationNotFoundError
   124  	ErrRemoteDestinationNotFoundError
   125  	ErrReplicationDestinationMissingLock
   126  	ErrRemoteTargetNotFoundError
   127  	ErrReplicationRemoteConnectionError
   128  	ErrReplicationBandwidthLimitError
   129  	ErrBucketRemoteIdenticalToSource
   130  	ErrBucketRemoteAlreadyExists
   131  	ErrBucketRemoteLabelInUse
   132  	ErrBucketRemoteArnTypeInvalid
   133  	ErrBucketRemoteArnInvalid
   134  	ErrBucketRemoteRemoveDisallowed
   135  	ErrRemoteTargetNotVersionedError
   136  	ErrReplicationSourceNotVersionedError
   137  	ErrReplicationNeedsVersioningError
   138  	ErrReplicationBucketNeedsVersioningError
   139  	ErrReplicationDenyEditError
   140  	ErrRemoteTargetDenyAddError
   141  	ErrReplicationNoExistingObjects
   142  	ErrReplicationValidationError
   143  	ErrReplicationPermissionCheckError
   144  	ErrObjectRestoreAlreadyInProgress
   145  	ErrNoSuchKey
   146  	ErrNoSuchUpload
   147  	ErrInvalidVersionID
   148  	ErrNoSuchVersion
   149  	ErrNotImplemented
   150  	ErrPreconditionFailed
   151  	ErrRequestTimeTooSkewed
   152  	ErrSignatureDoesNotMatch
   153  	ErrMethodNotAllowed
   154  	ErrInvalidPart
   155  	ErrInvalidPartOrder
   156  	ErrMissingPart
   157  	ErrAuthorizationHeaderMalformed
   158  	ErrMalformedPOSTRequest
   159  	ErrPOSTFileRequired
   160  	ErrSignatureVersionNotSupported
   161  	ErrBucketNotEmpty
   162  	ErrAllAccessDisabled
   163  	ErrPolicyInvalidVersion
   164  	ErrMissingFields
   165  	ErrMissingCredTag
   166  	ErrCredMalformed
   167  	ErrInvalidRegion
   168  	ErrInvalidServiceS3
   169  	ErrInvalidServiceSTS
   170  	ErrInvalidRequestVersion
   171  	ErrMissingSignTag
   172  	ErrMissingSignHeadersTag
   173  	ErrMalformedDate
   174  	ErrMalformedPresignedDate
   175  	ErrMalformedCredentialDate
   176  	ErrMalformedExpires
   177  	ErrNegativeExpires
   178  	ErrAuthHeaderEmpty
   179  	ErrExpiredPresignRequest
   180  	ErrRequestNotReadyYet
   181  	ErrUnsignedHeaders
   182  	ErrMissingDateHeader
   183  	ErrInvalidQuerySignatureAlgo
   184  	ErrInvalidQueryParams
   185  	ErrBucketAlreadyOwnedByYou
   186  	ErrInvalidDuration
   187  	ErrBucketAlreadyExists
   188  	ErrMetadataTooLarge
   189  	ErrUnsupportedMetadata
   190  	ErrUnsupportedHostHeader
   191  	ErrMaximumExpires
   192  	ErrSlowDownRead
   193  	ErrSlowDownWrite
   194  	ErrMaxVersionsExceeded
   195  	ErrInvalidPrefixMarker
   196  	ErrBadRequest
   197  	ErrKeyTooLongError
   198  	ErrInvalidBucketObjectLockConfiguration
   199  	ErrObjectLockConfigurationNotFound
   200  	ErrObjectLockConfigurationNotAllowed
   201  	ErrNoSuchObjectLockConfiguration
   202  	ErrObjectLocked
   203  	ErrInvalidRetentionDate
   204  	ErrPastObjectLockRetainDate
   205  	ErrUnknownWORMModeDirective
   206  	ErrBucketTaggingNotFound
   207  	ErrObjectLockInvalidHeaders
   208  	ErrInvalidTagDirective
   209  	ErrPolicyAlreadyAttached
   210  	ErrPolicyNotAttached
   211  	ErrExcessData
   212  	// Add new error codes here.
   213  
   214  	// SSE-S3/SSE-KMS related API errors
   215  	ErrInvalidEncryptionMethod
   216  	ErrInvalidEncryptionKeyID
   217  
   218  	// Server-Side-Encryption (with Customer provided key) related API errors.
   219  	ErrInsecureSSECustomerRequest
   220  	ErrSSEMultipartEncrypted
   221  	ErrSSEEncryptedObject
   222  	ErrInvalidEncryptionParameters
   223  	ErrInvalidEncryptionParametersSSEC
   224  
   225  	ErrInvalidSSECustomerAlgorithm
   226  	ErrInvalidSSECustomerKey
   227  	ErrMissingSSECustomerKey
   228  	ErrMissingSSECustomerKeyMD5
   229  	ErrSSECustomerKeyMD5Mismatch
   230  	ErrInvalidSSECustomerParameters
   231  	ErrIncompatibleEncryptionMethod
   232  	ErrKMSNotConfigured
   233  	ErrKMSKeyNotFoundException
   234  	ErrKMSDefaultKeyAlreadyConfigured
   235  
   236  	ErrNoAccessKey
   237  	ErrInvalidToken
   238  
   239  	// Bucket notification related errors.
   240  	ErrEventNotification
   241  	ErrARNNotification
   242  	ErrRegionNotification
   243  	ErrOverlappingFilterNotification
   244  	ErrFilterNameInvalid
   245  	ErrFilterNamePrefix
   246  	ErrFilterNameSuffix
   247  	ErrFilterValueInvalid
   248  	ErrOverlappingConfigs
   249  	ErrUnsupportedNotification
   250  
   251  	// S3 extended errors.
   252  	ErrContentSHA256Mismatch
   253  	ErrContentChecksumMismatch
   254  
   255  	// Add new extended error codes here.
   256  
   257  	// MinIO extended errors.
   258  	ErrStorageFull
   259  	ErrRequestBodyParse
   260  	ErrObjectExistsAsDirectory
   261  	ErrInvalidObjectName
   262  	ErrInvalidObjectNamePrefixSlash
   263  	ErrInvalidResourceName
   264  	ErrInvalidLifecycleQueryParameter
   265  	ErrServerNotInitialized
   266  	ErrRequestTimedout
   267  	ErrClientDisconnected
   268  	ErrTooManyRequests
   269  	ErrInvalidRequest
   270  	ErrTransitionStorageClassNotFoundError
   271  	// MinIO storage class error codes
   272  	ErrInvalidStorageClass
   273  	ErrBackendDown
   274  	// Add new extended error codes here.
   275  	// Please open a https://github.com/minio/minio/issues before adding
   276  	// new error codes here.
   277  
   278  	ErrMalformedJSON
   279  	ErrAdminNoSuchUser
   280  	ErrAdminNoSuchUserLDAPWarn
   281  	ErrAdminNoSuchGroup
   282  	ErrAdminGroupNotEmpty
   283  	ErrAdminGroupDisabled
   284  	ErrAdminNoSuchJob
   285  	ErrAdminNoSuchPolicy
   286  	ErrAdminPolicyChangeAlreadyApplied
   287  	ErrAdminInvalidArgument
   288  	ErrAdminInvalidAccessKey
   289  	ErrAdminInvalidSecretKey
   290  	ErrAdminConfigNoQuorum
   291  	ErrAdminConfigTooLarge
   292  	ErrAdminConfigBadJSON
   293  	ErrAdminNoSuchConfigTarget
   294  	ErrAdminConfigEnvOverridden
   295  	ErrAdminConfigDuplicateKeys
   296  	ErrAdminConfigInvalidIDPType
   297  	ErrAdminConfigLDAPNonDefaultConfigName
   298  	ErrAdminConfigLDAPValidation
   299  	ErrAdminConfigIDPCfgNameAlreadyExists
   300  	ErrAdminConfigIDPCfgNameDoesNotExist
   301  	ErrInsecureClientRequest
   302  	ErrObjectTampered
   303  
   304  	// Site-Replication errors
   305  	ErrSiteReplicationInvalidRequest
   306  	ErrSiteReplicationPeerResp
   307  	ErrSiteReplicationBackendIssue
   308  	ErrSiteReplicationServiceAccountError
   309  	ErrSiteReplicationBucketConfigError
   310  	ErrSiteReplicationBucketMetaError
   311  	ErrSiteReplicationIAMError
   312  	ErrSiteReplicationConfigMissing
   313  	ErrSiteReplicationIAMConfigMismatch
   314  
   315  	// Pool rebalance errors
   316  	ErrAdminRebalanceAlreadyStarted
   317  	ErrAdminRebalanceNotStarted
   318  
   319  	// Bucket Quota error codes
   320  	ErrAdminBucketQuotaExceeded
   321  	ErrAdminNoSuchQuotaConfiguration
   322  
   323  	ErrHealNotImplemented
   324  	ErrHealNoSuchProcess
   325  	ErrHealInvalidClientToken
   326  	ErrHealMissingBucket
   327  	ErrHealAlreadyRunning
   328  	ErrHealOverlappingPaths
   329  	ErrIncorrectContinuationToken
   330  
   331  	// S3 Select Errors
   332  	ErrEmptyRequestBody
   333  	ErrUnsupportedFunction
   334  	ErrInvalidExpressionType
   335  	ErrBusy
   336  	ErrUnauthorizedAccess
   337  	ErrExpressionTooLong
   338  	ErrIllegalSQLFunctionArgument
   339  	ErrInvalidKeyPath
   340  	ErrInvalidCompressionFormat
   341  	ErrInvalidFileHeaderInfo
   342  	ErrInvalidJSONType
   343  	ErrInvalidQuoteFields
   344  	ErrInvalidRequestParameter
   345  	ErrInvalidDataType
   346  	ErrInvalidTextEncoding
   347  	ErrInvalidDataSource
   348  	ErrInvalidTableAlias
   349  	ErrMissingRequiredParameter
   350  	ErrObjectSerializationConflict
   351  	ErrUnsupportedSQLOperation
   352  	ErrUnsupportedSQLStructure
   353  	ErrUnsupportedSyntax
   354  	ErrUnsupportedRangeHeader
   355  	ErrLexerInvalidChar
   356  	ErrLexerInvalidOperator
   357  	ErrLexerInvalidLiteral
   358  	ErrLexerInvalidIONLiteral
   359  	ErrParseExpectedDatePart
   360  	ErrParseExpectedKeyword
   361  	ErrParseExpectedTokenType
   362  	ErrParseExpected2TokenTypes
   363  	ErrParseExpectedNumber
   364  	ErrParseExpectedRightParenBuiltinFunctionCall
   365  	ErrParseExpectedTypeName
   366  	ErrParseExpectedWhenClause
   367  	ErrParseUnsupportedToken
   368  	ErrParseUnsupportedLiteralsGroupBy
   369  	ErrParseExpectedMember
   370  	ErrParseUnsupportedSelect
   371  	ErrParseUnsupportedCase
   372  	ErrParseUnsupportedCaseClause
   373  	ErrParseUnsupportedAlias
   374  	ErrParseUnsupportedSyntax
   375  	ErrParseUnknownOperator
   376  	ErrParseMissingIdentAfterAt
   377  	ErrParseUnexpectedOperator
   378  	ErrParseUnexpectedTerm
   379  	ErrParseUnexpectedToken
   380  	ErrParseUnexpectedKeyword
   381  	ErrParseExpectedExpression
   382  	ErrParseExpectedLeftParenAfterCast
   383  	ErrParseExpectedLeftParenValueConstructor
   384  	ErrParseExpectedLeftParenBuiltinFunctionCall
   385  	ErrParseExpectedArgumentDelimiter
   386  	ErrParseCastArity
   387  	ErrParseInvalidTypeParam
   388  	ErrParseEmptySelect
   389  	ErrParseSelectMissingFrom
   390  	ErrParseExpectedIdentForGroupName
   391  	ErrParseExpectedIdentForAlias
   392  	ErrParseUnsupportedCallWithStar
   393  	ErrParseNonUnaryAggregateFunctionCall
   394  	ErrParseMalformedJoin
   395  	ErrParseExpectedIdentForAt
   396  	ErrParseAsteriskIsNotAloneInSelectList
   397  	ErrParseCannotMixSqbAndWildcardInSelectList
   398  	ErrParseInvalidContextForWildcardInSelectList
   399  	ErrIncorrectSQLFunctionArgumentType
   400  	ErrValueParseFailure
   401  	ErrEvaluatorInvalidArguments
   402  	ErrIntegerOverflow
   403  	ErrLikeInvalidInputs
   404  	ErrCastFailed
   405  	ErrInvalidCast
   406  	ErrEvaluatorInvalidTimestampFormatPattern
   407  	ErrEvaluatorInvalidTimestampFormatPatternSymbolForParsing
   408  	ErrEvaluatorTimestampFormatPatternDuplicateFields
   409  	ErrEvaluatorTimestampFormatPatternHourClockAmPmMismatch
   410  	ErrEvaluatorUnterminatedTimestampFormatPatternToken
   411  	ErrEvaluatorInvalidTimestampFormatPatternToken
   412  	ErrEvaluatorInvalidTimestampFormatPatternSymbol
   413  	ErrEvaluatorBindingDoesNotExist
   414  	ErrMissingHeaders
   415  	ErrInvalidColumnIndex
   416  
   417  	ErrAdminConfigNotificationTargetsFailed
   418  	ErrAdminProfilerNotEnabled
   419  	ErrInvalidDecompressedSize
   420  	ErrAddUserInvalidArgument
   421  	ErrAdminResourceInvalidArgument
   422  	ErrAdminAccountNotEligible
   423  	ErrAccountNotEligible
   424  	ErrAdminServiceAccountNotFound
   425  	ErrPostPolicyConditionInvalidFormat
   426  
   427  	ErrInvalidChecksum
   428  
   429  	// Lambda functions
   430  	ErrLambdaARNInvalid
   431  	ErrLambdaARNNotFound
   432  
   433  	// New Codes for GetObjectAttributes and GetObjectVersionAttributes
   434  	ErrInvalidAttributeName
   435  
   436  	ErrAdminNoAccessKey
   437  	ErrAdminNoSecretKey
   438  
   439  	apiErrCodeEnd // This is used only for the testing code
   440  )
   441  
   442  type errorCodeMap map[APIErrorCode]APIError
   443  
   444  func (e errorCodeMap) ToAPIErrWithErr(errCode APIErrorCode, err error) APIError {
   445  	apiErr, ok := e[errCode]
   446  	if !ok {
   447  		apiErr = e[ErrInternalError]
   448  	}
   449  	if err != nil {
   450  		apiErr.Description = fmt.Sprintf("%s (%s)", apiErr.Description, err)
   451  	}
   452  	if globalSite.Region != "" {
   453  		if errCode == ErrAuthorizationHeaderMalformed {
   454  			apiErr.Description = fmt.Sprintf("The authorization header is malformed; the region is wrong; expecting '%s'.", globalSite.Region)
   455  			return apiErr
   456  		}
   457  	}
   458  	return apiErr
   459  }
   460  
   461  func (e errorCodeMap) ToAPIErr(errCode APIErrorCode) APIError {
   462  	return e.ToAPIErrWithErr(errCode, nil)
   463  }
   464  
   465  // error code to APIError structure, these fields carry respective
   466  // descriptions for all the error responses.
   467  var errorCodes = errorCodeMap{
   468  	ErrInvalidCopyDest: {
   469  		Code:           "InvalidRequest",
   470  		Description:    "This copy request is illegal because it is trying to copy an object to itself without changing the object's metadata, storage class, website redirect location or encryption attributes.",
   471  		HTTPStatusCode: http.StatusBadRequest,
   472  	},
   473  	ErrInvalidCopySource: {
   474  		Code:           "InvalidArgument",
   475  		Description:    "Copy Source must mention the source bucket and key: sourcebucket/sourcekey.",
   476  		HTTPStatusCode: http.StatusBadRequest,
   477  	},
   478  	ErrInvalidMetadataDirective: {
   479  		Code:           "InvalidArgument",
   480  		Description:    "Unknown metadata directive.",
   481  		HTTPStatusCode: http.StatusBadRequest,
   482  	},
   483  	ErrInvalidStorageClass: {
   484  		Code:           "InvalidStorageClass",
   485  		Description:    "Invalid storage class.",
   486  		HTTPStatusCode: http.StatusBadRequest,
   487  	},
   488  	ErrInvalidRequestBody: {
   489  		Code:           "InvalidArgument",
   490  		Description:    "Body shouldn't be set for this request.",
   491  		HTTPStatusCode: http.StatusBadRequest,
   492  	},
   493  	ErrInvalidMaxUploads: {
   494  		Code:           "InvalidArgument",
   495  		Description:    "Argument max-uploads must be an integer between 0 and 2147483647",
   496  		HTTPStatusCode: http.StatusBadRequest,
   497  	},
   498  	ErrInvalidMaxKeys: {
   499  		Code:           "InvalidArgument",
   500  		Description:    "Argument maxKeys must be an integer between 0 and 2147483647",
   501  		HTTPStatusCode: http.StatusBadRequest,
   502  	},
   503  	ErrInvalidEncodingMethod: {
   504  		Code:           "InvalidArgument",
   505  		Description:    "Invalid Encoding Method specified in Request",
   506  		HTTPStatusCode: http.StatusBadRequest,
   507  	},
   508  	ErrInvalidMaxParts: {
   509  		Code:           "InvalidArgument",
   510  		Description:    "Part number must be an integer between 1 and 10000, inclusive",
   511  		HTTPStatusCode: http.StatusBadRequest,
   512  	},
   513  	ErrInvalidPartNumberMarker: {
   514  		Code:           "InvalidArgument",
   515  		Description:    "Argument partNumberMarker must be an integer.",
   516  		HTTPStatusCode: http.StatusBadRequest,
   517  	},
   518  	ErrInvalidPartNumber: {
   519  		Code:           "InvalidPartNumber",
   520  		Description:    "The requested partnumber is not satisfiable",
   521  		HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
   522  	},
   523  	ErrInvalidPolicyDocument: {
   524  		Code:           "InvalidPolicyDocument",
   525  		Description:    "The content of the form does not meet the conditions specified in the policy document.",
   526  		HTTPStatusCode: http.StatusBadRequest,
   527  	},
   528  	ErrAccessDenied: {
   529  		Code:           "AccessDenied",
   530  		Description:    "Access Denied.",
   531  		HTTPStatusCode: http.StatusForbidden,
   532  	},
   533  	ErrBadDigest: {
   534  		Code:           "BadDigest",
   535  		Description:    "The Content-Md5 you specified did not match what we received.",
   536  		HTTPStatusCode: http.StatusBadRequest,
   537  	},
   538  	ErrEntityTooSmall: {
   539  		Code:           "EntityTooSmall",
   540  		Description:    "Your proposed upload is smaller than the minimum allowed object size.",
   541  		HTTPStatusCode: http.StatusBadRequest,
   542  	},
   543  	ErrEntityTooLarge: {
   544  		Code:           "EntityTooLarge",
   545  		Description:    "Your proposed upload exceeds the maximum allowed object size.",
   546  		HTTPStatusCode: http.StatusBadRequest,
   547  	},
   548  	ErrExcessData: {
   549  		Code:           "ExcessData",
   550  		Description:    "More data provided than indicated content length",
   551  		HTTPStatusCode: http.StatusBadRequest,
   552  	},
   553  	ErrPolicyTooLarge: {
   554  		Code:           "PolicyTooLarge",
   555  		Description:    "Policy exceeds the maximum allowed document size.",
   556  		HTTPStatusCode: http.StatusBadRequest,
   557  	},
   558  	ErrIncompleteBody: {
   559  		Code:           "IncompleteBody",
   560  		Description:    "You did not provide the number of bytes specified by the Content-Length HTTP header.",
   561  		HTTPStatusCode: http.StatusBadRequest,
   562  	},
   563  	ErrInternalError: {
   564  		Code:           "InternalError",
   565  		Description:    "We encountered an internal error, please try again.",
   566  		HTTPStatusCode: http.StatusInternalServerError,
   567  	},
   568  	ErrInvalidAccessKeyID: {
   569  		Code:           "InvalidAccessKeyId",
   570  		Description:    "The Access Key Id you provided does not exist in our records.",
   571  		HTTPStatusCode: http.StatusForbidden,
   572  	},
   573  	ErrAccessKeyDisabled: {
   574  		Code:           "InvalidAccessKeyId",
   575  		Description:    "Your account is disabled; please contact your administrator.",
   576  		HTTPStatusCode: http.StatusForbidden,
   577  	},
   578  	ErrInvalidArgument: {
   579  		Code:           "InvalidArgument",
   580  		Description:    "Invalid argument",
   581  		HTTPStatusCode: http.StatusBadRequest,
   582  	},
   583  	ErrInvalidBucketName: {
   584  		Code:           "InvalidBucketName",
   585  		Description:    "The specified bucket is not valid.",
   586  		HTTPStatusCode: http.StatusBadRequest,
   587  	},
   588  	ErrInvalidDigest: {
   589  		Code:           "InvalidDigest",
   590  		Description:    "The Content-Md5 you specified is not valid.",
   591  		HTTPStatusCode: http.StatusBadRequest,
   592  	},
   593  	ErrInvalidRange: {
   594  		Code:           "InvalidRange",
   595  		Description:    "The requested range is not satisfiable",
   596  		HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
   597  	},
   598  	ErrInvalidRangePartNumber: {
   599  		Code:           "InvalidRequest",
   600  		Description:    "Cannot specify both Range header and partNumber query parameter",
   601  		HTTPStatusCode: http.StatusBadRequest,
   602  	},
   603  	ErrMalformedXML: {
   604  		Code:           "MalformedXML",
   605  		Description:    "The XML you provided was not well-formed or did not validate against our published schema.",
   606  		HTTPStatusCode: http.StatusBadRequest,
   607  	},
   608  	ErrMissingContentLength: {
   609  		Code:           "MissingContentLength",
   610  		Description:    "You must provide the Content-Length HTTP header.",
   611  		HTTPStatusCode: http.StatusLengthRequired,
   612  	},
   613  	ErrMissingContentMD5: {
   614  		Code:           "MissingContentMD5",
   615  		Description:    "Missing required header for this request: Content-Md5.",
   616  		HTTPStatusCode: http.StatusBadRequest,
   617  	},
   618  	ErrMissingSecurityHeader: {
   619  		Code:           "MissingSecurityHeader",
   620  		Description:    "Your request was missing a required header",
   621  		HTTPStatusCode: http.StatusBadRequest,
   622  	},
   623  	ErrMissingRequestBodyError: {
   624  		Code:           "MissingRequestBodyError",
   625  		Description:    "Request body is empty.",
   626  		HTTPStatusCode: http.StatusLengthRequired,
   627  	},
   628  	ErrNoSuchBucket: {
   629  		Code:           "NoSuchBucket",
   630  		Description:    "The specified bucket does not exist",
   631  		HTTPStatusCode: http.StatusNotFound,
   632  	},
   633  	ErrNoSuchBucketPolicy: {
   634  		Code:           "NoSuchBucketPolicy",
   635  		Description:    "The bucket policy does not exist",
   636  		HTTPStatusCode: http.StatusNotFound,
   637  	},
   638  	ErrNoSuchBucketLifecycle: {
   639  		Code:           "NoSuchBucketLifecycle",
   640  		Description:    "The bucket lifecycle configuration does not exist",
   641  		HTTPStatusCode: http.StatusNotFound,
   642  	},
   643  	ErrNoSuchLifecycleConfiguration: {
   644  		Code:           "NoSuchLifecycleConfiguration",
   645  		Description:    "The lifecycle configuration does not exist",
   646  		HTTPStatusCode: http.StatusNotFound,
   647  	},
   648  	ErrInvalidLifecycleWithObjectLock: {
   649  		Code:           "InvalidLifecycleWithObjectLock",
   650  		Description:    "The lifecycle configuration containing MaxNoncurrentVersions is not supported with object locking",
   651  		HTTPStatusCode: http.StatusBadRequest,
   652  	},
   653  	ErrNoSuchBucketSSEConfig: {
   654  		Code:           "ServerSideEncryptionConfigurationNotFoundError",
   655  		Description:    "The server side encryption configuration was not found",
   656  		HTTPStatusCode: http.StatusNotFound,
   657  	},
   658  	ErrNoSuchKey: {
   659  		Code:           "NoSuchKey",
   660  		Description:    "The specified key does not exist.",
   661  		HTTPStatusCode: http.StatusNotFound,
   662  	},
   663  	ErrNoSuchUpload: {
   664  		Code:           "NoSuchUpload",
   665  		Description:    "The specified multipart upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",
   666  		HTTPStatusCode: http.StatusNotFound,
   667  	},
   668  	ErrInvalidVersionID: {
   669  		Code:           "InvalidArgument",
   670  		Description:    "Invalid version id specified",
   671  		HTTPStatusCode: http.StatusBadRequest,
   672  	},
   673  	ErrNoSuchVersion: {
   674  		Code:           "NoSuchVersion",
   675  		Description:    "The specified version does not exist.",
   676  		HTTPStatusCode: http.StatusNotFound,
   677  	},
   678  	ErrNotImplemented: {
   679  		Code:           "NotImplemented",
   680  		Description:    "A header you provided implies functionality that is not implemented",
   681  		HTTPStatusCode: http.StatusNotImplemented,
   682  	},
   683  	ErrPreconditionFailed: {
   684  		Code:           "PreconditionFailed",
   685  		Description:    "At least one of the pre-conditions you specified did not hold",
   686  		HTTPStatusCode: http.StatusPreconditionFailed,
   687  	},
   688  	ErrRequestTimeTooSkewed: {
   689  		Code:           "RequestTimeTooSkewed",
   690  		Description:    "The difference between the request time and the server's time is too large.",
   691  		HTTPStatusCode: http.StatusForbidden,
   692  	},
   693  	ErrSignatureDoesNotMatch: {
   694  		Code:           "SignatureDoesNotMatch",
   695  		Description:    "The request signature we calculated does not match the signature you provided. Check your key and signing method.",
   696  		HTTPStatusCode: http.StatusForbidden,
   697  	},
   698  	ErrMethodNotAllowed: {
   699  		Code:           "MethodNotAllowed",
   700  		Description:    "The specified method is not allowed against this resource.",
   701  		HTTPStatusCode: http.StatusMethodNotAllowed,
   702  	},
   703  	ErrInvalidPart: {
   704  		Code:           "InvalidPart",
   705  		Description:    "One or more of the specified parts could not be found.  The part may not have been uploaded, or the specified entity tag may not match the part's entity tag.",
   706  		HTTPStatusCode: http.StatusBadRequest,
   707  	},
   708  	ErrMissingPart: {
   709  		Code:           "InvalidRequest",
   710  		Description:    "You must specify at least one part",
   711  		HTTPStatusCode: http.StatusBadRequest,
   712  	},
   713  	ErrInvalidPartOrder: {
   714  		Code:           "InvalidPartOrder",
   715  		Description:    "The list of parts was not in ascending order. The parts list must be specified in order by part number.",
   716  		HTTPStatusCode: http.StatusBadRequest,
   717  	},
   718  	ErrInvalidObjectState: {
   719  		Code:           "InvalidObjectState",
   720  		Description:    "The operation is not valid for the current state of the object.",
   721  		HTTPStatusCode: http.StatusForbidden,
   722  	},
   723  	ErrAuthorizationHeaderMalformed: {
   724  		Code:           "AuthorizationHeaderMalformed",
   725  		Description:    "The authorization header is malformed; the region is wrong; expecting 'us-east-1'.",
   726  		HTTPStatusCode: http.StatusBadRequest,
   727  	},
   728  	ErrMalformedPOSTRequest: {
   729  		Code:           "MalformedPOSTRequest",
   730  		Description:    "The body of your POST request is not well-formed multipart/form-data.",
   731  		HTTPStatusCode: http.StatusBadRequest,
   732  	},
   733  	ErrPOSTFileRequired: {
   734  		Code:           "InvalidArgument",
   735  		Description:    "POST requires exactly one file upload per request.",
   736  		HTTPStatusCode: http.StatusBadRequest,
   737  	},
   738  	ErrSignatureVersionNotSupported: {
   739  		Code:           "InvalidRequest",
   740  		Description:    "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.",
   741  		HTTPStatusCode: http.StatusBadRequest,
   742  	},
   743  	ErrBucketNotEmpty: {
   744  		Code:           "BucketNotEmpty",
   745  		Description:    "The bucket you tried to delete is not empty",
   746  		HTTPStatusCode: http.StatusConflict,
   747  	},
   748  	ErrBucketAlreadyExists: {
   749  		Code:           "BucketAlreadyExists",
   750  		Description:    "The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.",
   751  		HTTPStatusCode: http.StatusConflict,
   752  	},
   753  	ErrAllAccessDisabled: {
   754  		Code:           "AllAccessDisabled",
   755  		Description:    "All access to this resource has been disabled.",
   756  		HTTPStatusCode: http.StatusForbidden,
   757  	},
   758  	ErrPolicyInvalidVersion: {
   759  		Code:           "MalformedPolicy",
   760  		Description:    "The policy must contain a valid version string",
   761  		HTTPStatusCode: http.StatusBadRequest,
   762  	},
   763  	ErrMissingFields: {
   764  		Code:           "MissingFields",
   765  		Description:    "Missing fields in request.",
   766  		HTTPStatusCode: http.StatusBadRequest,
   767  	},
   768  	ErrMissingCredTag: {
   769  		Code:           "InvalidRequest",
   770  		Description:    "Missing Credential field for this request.",
   771  		HTTPStatusCode: http.StatusBadRequest,
   772  	},
   773  	ErrCredMalformed: {
   774  		Code:           "AuthorizationQueryParametersError",
   775  		Description:    "Error parsing the X-Amz-Credential parameter; the Credential is mal-formed; expecting \"<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request\".",
   776  		HTTPStatusCode: http.StatusBadRequest,
   777  	},
   778  	ErrMalformedDate: {
   779  		Code:           "MalformedDate",
   780  		Description:    "Invalid date format header, expected to be in ISO8601, RFC1123 or RFC1123Z time format.",
   781  		HTTPStatusCode: http.StatusBadRequest,
   782  	},
   783  	ErrMalformedPresignedDate: {
   784  		Code:           "AuthorizationQueryParametersError",
   785  		Description:    "X-Amz-Date must be in the ISO8601 Long Format \"yyyyMMdd'T'HHmmss'Z'\"",
   786  		HTTPStatusCode: http.StatusBadRequest,
   787  	},
   788  	ErrMalformedCredentialDate: {
   789  		Code:           "AuthorizationQueryParametersError",
   790  		Description:    "Error parsing the X-Amz-Credential parameter; incorrect date format. This date in the credential must be in the format \"yyyyMMdd\".",
   791  		HTTPStatusCode: http.StatusBadRequest,
   792  	},
   793  	ErrInvalidRegion: {
   794  		Code:           "InvalidRegion",
   795  		Description:    "Region does not match.",
   796  		HTTPStatusCode: http.StatusBadRequest,
   797  	},
   798  	ErrInvalidServiceS3: {
   799  		Code:           "AuthorizationParametersError",
   800  		Description:    "Error parsing the Credential/X-Amz-Credential parameter; incorrect service. This endpoint belongs to \"s3\".",
   801  		HTTPStatusCode: http.StatusBadRequest,
   802  	},
   803  	ErrInvalidServiceSTS: {
   804  		Code:           "AuthorizationParametersError",
   805  		Description:    "Error parsing the Credential parameter; incorrect service. This endpoint belongs to \"sts\".",
   806  		HTTPStatusCode: http.StatusBadRequest,
   807  	},
   808  	ErrInvalidRequestVersion: {
   809  		Code:           "AuthorizationQueryParametersError",
   810  		Description:    "Error parsing the X-Amz-Credential parameter; incorrect terminal. This endpoint uses \"aws4_request\".",
   811  		HTTPStatusCode: http.StatusBadRequest,
   812  	},
   813  	ErrMissingSignTag: {
   814  		Code:           "AccessDenied",
   815  		Description:    "Signature header missing Signature field.",
   816  		HTTPStatusCode: http.StatusBadRequest,
   817  	},
   818  	ErrMissingSignHeadersTag: {
   819  		Code:           "InvalidArgument",
   820  		Description:    "Signature header missing SignedHeaders field.",
   821  		HTTPStatusCode: http.StatusBadRequest,
   822  	},
   823  	ErrMalformedExpires: {
   824  		Code:           "AuthorizationQueryParametersError",
   825  		Description:    "X-Amz-Expires should be a number",
   826  		HTTPStatusCode: http.StatusBadRequest,
   827  	},
   828  	ErrNegativeExpires: {
   829  		Code:           "AuthorizationQueryParametersError",
   830  		Description:    "X-Amz-Expires must be non-negative",
   831  		HTTPStatusCode: http.StatusBadRequest,
   832  	},
   833  	ErrAuthHeaderEmpty: {
   834  		Code:           "InvalidArgument",
   835  		Description:    "Authorization header is invalid -- one and only one ' ' (space) required.",
   836  		HTTPStatusCode: http.StatusBadRequest,
   837  	},
   838  	ErrMissingDateHeader: {
   839  		Code:           "AccessDenied",
   840  		Description:    "AWS authentication requires a valid Date or x-amz-date header",
   841  		HTTPStatusCode: http.StatusBadRequest,
   842  	},
   843  	ErrInvalidQuerySignatureAlgo: {
   844  		Code:           "AuthorizationQueryParametersError",
   845  		Description:    "X-Amz-Algorithm only supports \"AWS4-HMAC-SHA256\".",
   846  		HTTPStatusCode: http.StatusBadRequest,
   847  	},
   848  	ErrExpiredPresignRequest: {
   849  		Code:           "AccessDenied",
   850  		Description:    "Request has expired",
   851  		HTTPStatusCode: http.StatusForbidden,
   852  	},
   853  	ErrRequestNotReadyYet: {
   854  		Code:           "AccessDenied",
   855  		Description:    "Request is not valid yet",
   856  		HTTPStatusCode: http.StatusForbidden,
   857  	},
   858  	ErrSlowDownRead: {
   859  		Code:           "SlowDownRead",
   860  		Description:    "Resource requested is unreadable, please reduce your request rate",
   861  		HTTPStatusCode: http.StatusServiceUnavailable,
   862  	},
   863  	ErrSlowDownWrite: {
   864  		Code:           "SlowDownWrite",
   865  		Description:    "Resource requested is unwritable, please reduce your request rate",
   866  		HTTPStatusCode: http.StatusServiceUnavailable,
   867  	},
   868  	ErrMaxVersionsExceeded: {
   869  		Code:           "MaxVersionsExceeded",
   870  		Description:    "You've exceeded the limit on the number of versions you can create on this object",
   871  		HTTPStatusCode: http.StatusBadRequest,
   872  	},
   873  	ErrInvalidPrefixMarker: {
   874  		Code:           "InvalidPrefixMarker",
   875  		Description:    "Invalid marker prefix combination",
   876  		HTTPStatusCode: http.StatusBadRequest,
   877  	},
   878  	ErrBadRequest: {
   879  		Code:           "BadRequest",
   880  		Description:    "400 BadRequest",
   881  		HTTPStatusCode: http.StatusBadRequest,
   882  	},
   883  	ErrKeyTooLongError: {
   884  		Code:           "KeyTooLongError",
   885  		Description:    "Your key is too long",
   886  		HTTPStatusCode: http.StatusBadRequest,
   887  	},
   888  	ErrUnsignedHeaders: {
   889  		Code:           "AccessDenied",
   890  		Description:    "There were headers present in the request which were not signed",
   891  		HTTPStatusCode: http.StatusBadRequest,
   892  	},
   893  	ErrInvalidQueryParams: {
   894  		Code:           "AuthorizationQueryParametersError",
   895  		Description:    "Query-string authentication version 4 requires the X-Amz-Algorithm, X-Amz-Credential, X-Amz-Signature, X-Amz-Date, X-Amz-SignedHeaders, and X-Amz-Expires parameters.",
   896  		HTTPStatusCode: http.StatusBadRequest,
   897  	},
   898  	ErrBucketAlreadyOwnedByYou: {
   899  		Code:           "BucketAlreadyOwnedByYou",
   900  		Description:    "Your previous request to create the named bucket succeeded and you already own it.",
   901  		HTTPStatusCode: http.StatusConflict,
   902  	},
   903  	ErrInvalidDuration: {
   904  		Code:           "InvalidDuration",
   905  		Description:    "Duration provided in the request is invalid.",
   906  		HTTPStatusCode: http.StatusBadRequest,
   907  	},
   908  	ErrInvalidBucketObjectLockConfiguration: {
   909  		Code:           "InvalidRequest",
   910  		Description:    "Bucket is missing ObjectLockConfiguration",
   911  		HTTPStatusCode: http.StatusBadRequest,
   912  	},
   913  	ErrBucketTaggingNotFound: {
   914  		Code:           "NoSuchTagSet",
   915  		Description:    "The TagSet does not exist",
   916  		HTTPStatusCode: http.StatusNotFound,
   917  	},
   918  	ErrObjectLockConfigurationNotFound: {
   919  		Code:           "ObjectLockConfigurationNotFoundError",
   920  		Description:    "Object Lock configuration does not exist for this bucket",
   921  		HTTPStatusCode: http.StatusNotFound,
   922  	},
   923  	ErrObjectLockConfigurationNotAllowed: {
   924  		Code:           "InvalidBucketState",
   925  		Description:    "Object Lock configuration cannot be enabled on existing buckets",
   926  		HTTPStatusCode: http.StatusConflict,
   927  	},
   928  	ErrNoSuchCORSConfiguration: {
   929  		Code:           "NoSuchCORSConfiguration",
   930  		Description:    "The CORS configuration does not exist",
   931  		HTTPStatusCode: http.StatusNotFound,
   932  	},
   933  	ErrNoSuchWebsiteConfiguration: {
   934  		Code:           "NoSuchWebsiteConfiguration",
   935  		Description:    "The specified bucket does not have a website configuration",
   936  		HTTPStatusCode: http.StatusNotFound,
   937  	},
   938  	ErrReplicationConfigurationNotFoundError: {
   939  		Code:           "ReplicationConfigurationNotFoundError",
   940  		Description:    "The replication configuration was not found",
   941  		HTTPStatusCode: http.StatusNotFound,
   942  	},
   943  	ErrRemoteDestinationNotFoundError: {
   944  		Code:           "RemoteDestinationNotFoundError",
   945  		Description:    "The remote destination bucket does not exist",
   946  		HTTPStatusCode: http.StatusNotFound,
   947  	},
   948  	ErrReplicationDestinationMissingLock: {
   949  		Code:           "ReplicationDestinationMissingLockError",
   950  		Description:    "The replication destination bucket does not have object locking enabled",
   951  		HTTPStatusCode: http.StatusBadRequest,
   952  	},
   953  	ErrRemoteTargetNotFoundError: {
   954  		Code:           "XMinioAdminRemoteTargetNotFoundError",
   955  		Description:    "The remote target does not exist",
   956  		HTTPStatusCode: http.StatusNotFound,
   957  	},
   958  	ErrReplicationRemoteConnectionError: {
   959  		Code:           "XMinioAdminReplicationRemoteConnectionError",
   960  		Description:    "Remote service connection error",
   961  		HTTPStatusCode: http.StatusNotFound,
   962  	},
   963  	ErrReplicationBandwidthLimitError: {
   964  		Code:           "XMinioAdminReplicationBandwidthLimitError",
   965  		Description:    "Bandwidth limit for remote target must be at least 100MBps",
   966  		HTTPStatusCode: http.StatusBadRequest,
   967  	},
   968  	ErrReplicationNoExistingObjects: {
   969  		Code:           "XMinioReplicationNoExistingObjects",
   970  		Description:    "No matching ExistingsObjects rule enabled",
   971  		HTTPStatusCode: http.StatusBadRequest,
   972  	},
   973  	ErrRemoteTargetDenyAddError: {
   974  		Code:           "XMinioAdminRemoteTargetDenyAdd",
   975  		Description:    "Cannot add remote target endpoint since this server is in a cluster replication setup",
   976  		HTTPStatusCode: http.StatusBadRequest,
   977  	},
   978  	ErrReplicationDenyEditError: {
   979  		Code:           "XMinioReplicationDenyEdit",
   980  		Description:    "Cannot alter local replication config since this server is in a cluster replication setup",
   981  		HTTPStatusCode: http.StatusBadRequest,
   982  	},
   983  	ErrBucketRemoteIdenticalToSource: {
   984  		Code:           "XMinioAdminRemoteIdenticalToSource",
   985  		Description:    "The remote target cannot be identical to source",
   986  		HTTPStatusCode: http.StatusBadRequest,
   987  	},
   988  	ErrBucketRemoteAlreadyExists: {
   989  		Code:           "XMinioAdminBucketRemoteAlreadyExists",
   990  		Description:    "The remote target already exists",
   991  		HTTPStatusCode: http.StatusBadRequest,
   992  	},
   993  	ErrBucketRemoteLabelInUse: {
   994  		Code:           "XMinioAdminBucketRemoteLabelInUse",
   995  		Description:    "The remote target with this label already exists",
   996  		HTTPStatusCode: http.StatusBadRequest,
   997  	},
   998  	ErrBucketRemoteRemoveDisallowed: {
   999  		Code:           "XMinioAdminRemoteRemoveDisallowed",
  1000  		Description:    "This ARN is in use by an existing configuration",
  1001  		HTTPStatusCode: http.StatusBadRequest,
  1002  	},
  1003  	ErrBucketRemoteArnTypeInvalid: {
  1004  		Code:           "XMinioAdminRemoteARNTypeInvalid",
  1005  		Description:    "The bucket remote ARN type is not valid",
  1006  		HTTPStatusCode: http.StatusBadRequest,
  1007  	},
  1008  	ErrBucketRemoteArnInvalid: {
  1009  		Code:           "XMinioAdminRemoteArnInvalid",
  1010  		Description:    "The bucket remote ARN does not have correct format",
  1011  		HTTPStatusCode: http.StatusBadRequest,
  1012  	},
  1013  	ErrRemoteTargetNotVersionedError: {
  1014  		Code:           "RemoteTargetNotVersionedError",
  1015  		Description:    "The remote target does not have versioning enabled",
  1016  		HTTPStatusCode: http.StatusBadRequest,
  1017  	},
  1018  	ErrReplicationSourceNotVersionedError: {
  1019  		Code:           "ReplicationSourceNotVersionedError",
  1020  		Description:    "The replication source does not have versioning enabled",
  1021  		HTTPStatusCode: http.StatusBadRequest,
  1022  	},
  1023  	ErrReplicationNeedsVersioningError: {
  1024  		Code:           "InvalidRequest",
  1025  		Description:    "Versioning must be 'Enabled' on the bucket to apply a replication configuration",
  1026  		HTTPStatusCode: http.StatusBadRequest,
  1027  	},
  1028  	ErrReplicationBucketNeedsVersioningError: {
  1029  		Code:           "InvalidRequest",
  1030  		Description:    "Versioning must be 'Enabled' on the bucket to add a replication target",
  1031  		HTTPStatusCode: http.StatusBadRequest,
  1032  	},
  1033  	ErrReplicationValidationError: {
  1034  		Code:           "InvalidRequest",
  1035  		Description:    "Replication validation failed on target",
  1036  		HTTPStatusCode: http.StatusBadRequest,
  1037  	},
  1038  	ErrReplicationPermissionCheckError: {
  1039  		Code:           "ReplicationPermissionCheck",
  1040  		Description:    "X-Minio-Source-Replication-Check cannot be specified in request. Request cannot be completed",
  1041  		HTTPStatusCode: http.StatusBadRequest,
  1042  	},
  1043  	ErrNoSuchObjectLockConfiguration: {
  1044  		Code:           "NoSuchObjectLockConfiguration",
  1045  		Description:    "The specified object does not have a ObjectLock configuration",
  1046  		HTTPStatusCode: http.StatusBadRequest,
  1047  	},
  1048  	ErrObjectLocked: {
  1049  		Code:           "InvalidRequest",
  1050  		Description:    "Object is WORM protected and cannot be overwritten",
  1051  		HTTPStatusCode: http.StatusBadRequest,
  1052  	},
  1053  	ErrInvalidRetentionDate: {
  1054  		Code:           "InvalidRequest",
  1055  		Description:    "Date must be provided in ISO 8601 format",
  1056  		HTTPStatusCode: http.StatusBadRequest,
  1057  	},
  1058  	ErrPastObjectLockRetainDate: {
  1059  		Code:           "InvalidRequest",
  1060  		Description:    "the retain until date must be in the future",
  1061  		HTTPStatusCode: http.StatusBadRequest,
  1062  	},
  1063  	ErrUnknownWORMModeDirective: {
  1064  		Code:           "InvalidRequest",
  1065  		Description:    "unknown wormMode directive",
  1066  		HTTPStatusCode: http.StatusBadRequest,
  1067  	},
  1068  	ErrObjectLockInvalidHeaders: {
  1069  		Code:           "InvalidRequest",
  1070  		Description:    "x-amz-object-lock-retain-until-date and x-amz-object-lock-mode must both be supplied",
  1071  		HTTPStatusCode: http.StatusBadRequest,
  1072  	},
  1073  	ErrObjectRestoreAlreadyInProgress: {
  1074  		Code:           "RestoreAlreadyInProgress",
  1075  		Description:    "Object restore is already in progress",
  1076  		HTTPStatusCode: http.StatusConflict,
  1077  	},
  1078  	ErrTransitionStorageClassNotFoundError: {
  1079  		Code:           "TransitionStorageClassNotFoundError",
  1080  		Description:    "The transition storage class was not found",
  1081  		HTTPStatusCode: http.StatusNotFound,
  1082  	},
  1083  
  1084  	// Bucket notification related errors.
  1085  	ErrEventNotification: {
  1086  		Code:           "InvalidArgument",
  1087  		Description:    "A specified event is not supported for notifications.",
  1088  		HTTPStatusCode: http.StatusBadRequest,
  1089  	},
  1090  	ErrARNNotification: {
  1091  		Code:           "InvalidArgument",
  1092  		Description:    "A specified destination ARN does not exist or is not well-formed. Verify the destination ARN.",
  1093  		HTTPStatusCode: http.StatusBadRequest,
  1094  	},
  1095  	ErrRegionNotification: {
  1096  		Code:           "InvalidArgument",
  1097  		Description:    "A specified destination is in a different region than the bucket. You must use a destination that resides in the same region as the bucket.",
  1098  		HTTPStatusCode: http.StatusBadRequest,
  1099  	},
  1100  	ErrOverlappingFilterNotification: {
  1101  		Code:           "InvalidArgument",
  1102  		Description:    "An object key name filtering rule defined with overlapping prefixes, overlapping suffixes, or overlapping combinations of prefixes and suffixes for the same event types.",
  1103  		HTTPStatusCode: http.StatusBadRequest,
  1104  	},
  1105  	ErrFilterNameInvalid: {
  1106  		Code:           "InvalidArgument",
  1107  		Description:    "filter rule name must be either prefix or suffix",
  1108  		HTTPStatusCode: http.StatusBadRequest,
  1109  	},
  1110  	ErrFilterNamePrefix: {
  1111  		Code:           "InvalidArgument",
  1112  		Description:    "Cannot specify more than one prefix rule in a filter.",
  1113  		HTTPStatusCode: http.StatusBadRequest,
  1114  	},
  1115  	ErrFilterNameSuffix: {
  1116  		Code:           "InvalidArgument",
  1117  		Description:    "Cannot specify more than one suffix rule in a filter.",
  1118  		HTTPStatusCode: http.StatusBadRequest,
  1119  	},
  1120  	ErrFilterValueInvalid: {
  1121  		Code:           "InvalidArgument",
  1122  		Description:    "Size of filter rule value cannot exceed 1024 bytes in UTF-8 representation",
  1123  		HTTPStatusCode: http.StatusBadRequest,
  1124  	},
  1125  	ErrOverlappingConfigs: {
  1126  		Code:           "InvalidArgument",
  1127  		Description:    "Configurations overlap. Configurations on the same bucket cannot share a common event type.",
  1128  		HTTPStatusCode: http.StatusBadRequest,
  1129  	},
  1130  	ErrUnsupportedNotification: {
  1131  		Code:           "UnsupportedNotification",
  1132  		Description:    "MinIO server does not support Topic or Cloud Function based notifications.",
  1133  		HTTPStatusCode: http.StatusBadRequest,
  1134  	},
  1135  	ErrInvalidCopyPartRange: {
  1136  		Code:           "InvalidArgument",
  1137  		Description:    "The x-amz-copy-source-range value must be of the form bytes=first-last where first and last are the zero-based offsets of the first and last bytes to copy",
  1138  		HTTPStatusCode: http.StatusBadRequest,
  1139  	},
  1140  	ErrInvalidCopyPartRangeSource: {
  1141  		Code:           "InvalidArgument",
  1142  		Description:    "Range specified is not valid for source object",
  1143  		HTTPStatusCode: http.StatusBadRequest,
  1144  	},
  1145  	ErrMetadataTooLarge: {
  1146  		Code:           "MetadataTooLarge",
  1147  		Description:    "Your metadata headers exceed the maximum allowed metadata size.",
  1148  		HTTPStatusCode: http.StatusBadRequest,
  1149  	},
  1150  	ErrInvalidTagDirective: {
  1151  		Code:           "InvalidArgument",
  1152  		Description:    "Unknown tag directive.",
  1153  		HTTPStatusCode: http.StatusBadRequest,
  1154  	},
  1155  	ErrInvalidEncryptionMethod: {
  1156  		Code:           "InvalidArgument",
  1157  		Description:    "Server Side Encryption with AWS KMS managed key requires HTTP header x-amz-server-side-encryption : aws:kms",
  1158  		HTTPStatusCode: http.StatusBadRequest,
  1159  	},
  1160  	ErrIncompatibleEncryptionMethod: {
  1161  		Code:           "InvalidArgument",
  1162  		Description:    "Server Side Encryption with Customer provided key is incompatible with the encryption method specified",
  1163  		HTTPStatusCode: http.StatusBadRequest,
  1164  	},
  1165  	ErrInvalidEncryptionKeyID: {
  1166  		Code:           "InvalidRequest",
  1167  		Description:    "The specified KMS KeyID contains unsupported characters",
  1168  		HTTPStatusCode: http.StatusBadRequest,
  1169  	},
  1170  	ErrInsecureSSECustomerRequest: {
  1171  		Code:           "InvalidRequest",
  1172  		Description:    "Requests specifying Server Side Encryption with Customer provided keys must be made over a secure connection.",
  1173  		HTTPStatusCode: http.StatusBadRequest,
  1174  	},
  1175  	ErrSSEMultipartEncrypted: {
  1176  		Code:           "InvalidRequest",
  1177  		Description:    "The multipart upload initiate requested encryption. Subsequent part requests must include the appropriate encryption parameters.",
  1178  		HTTPStatusCode: http.StatusBadRequest,
  1179  	},
  1180  	ErrSSEEncryptedObject: {
  1181  		Code:           "InvalidRequest",
  1182  		Description:    "The object was stored using a form of Server Side Encryption. The correct parameters must be provided to retrieve the object.",
  1183  		HTTPStatusCode: http.StatusBadRequest,
  1184  	},
  1185  	ErrInvalidEncryptionParameters: {
  1186  		Code:           "InvalidRequest",
  1187  		Description:    "The encryption parameters are not applicable to this object.",
  1188  		HTTPStatusCode: http.StatusBadRequest,
  1189  	},
  1190  	ErrInvalidEncryptionParametersSSEC: {
  1191  		Code:           "InvalidRequest",
  1192  		Description:    "SSE-C encryption parameters are not supported on replicated bucket.",
  1193  		HTTPStatusCode: http.StatusBadRequest,
  1194  	},
  1195  	ErrInvalidSSECustomerAlgorithm: {
  1196  		Code:           "InvalidArgument",
  1197  		Description:    "Requests specifying Server Side Encryption with Customer provided keys must provide a valid encryption algorithm.",
  1198  		HTTPStatusCode: http.StatusBadRequest,
  1199  	},
  1200  	ErrInvalidSSECustomerKey: {
  1201  		Code:           "InvalidArgument",
  1202  		Description:    "The secret key was invalid for the specified algorithm.",
  1203  		HTTPStatusCode: http.StatusBadRequest,
  1204  	},
  1205  	ErrMissingSSECustomerKey: {
  1206  		Code:           "InvalidArgument",
  1207  		Description:    "Requests specifying Server Side Encryption with Customer provided keys must provide an appropriate secret key.",
  1208  		HTTPStatusCode: http.StatusBadRequest,
  1209  	},
  1210  	ErrMissingSSECustomerKeyMD5: {
  1211  		Code:           "InvalidArgument",
  1212  		Description:    "Requests specifying Server Side Encryption with Customer provided keys must provide the client calculated MD5 of the secret key.",
  1213  		HTTPStatusCode: http.StatusBadRequest,
  1214  	},
  1215  	ErrSSECustomerKeyMD5Mismatch: {
  1216  		Code:           "InvalidArgument",
  1217  		Description:    "The calculated MD5 hash of the key did not match the hash that was provided.",
  1218  		HTTPStatusCode: http.StatusBadRequest,
  1219  	},
  1220  	ErrInvalidSSECustomerParameters: {
  1221  		Code:           "InvalidArgument",
  1222  		Description:    "The provided encryption parameters did not match the ones used originally.",
  1223  		HTTPStatusCode: http.StatusBadRequest,
  1224  	},
  1225  	ErrKMSNotConfigured: {
  1226  		Code:           "NotImplemented",
  1227  		Description:    "Server side encryption specified but KMS is not configured",
  1228  		HTTPStatusCode: http.StatusNotImplemented,
  1229  	},
  1230  	ErrKMSKeyNotFoundException: {
  1231  		Code:           "KMS.NotFoundException",
  1232  		Description:    "Invalid keyId",
  1233  		HTTPStatusCode: http.StatusBadRequest,
  1234  	},
  1235  	ErrKMSDefaultKeyAlreadyConfigured: {
  1236  		Code:           "KMS.DefaultKeyAlreadyConfiguredException",
  1237  		Description:    "A default encryption already exists and cannot be changed on KMS",
  1238  		HTTPStatusCode: http.StatusConflict,
  1239  	},
  1240  	ErrNoAccessKey: {
  1241  		Code:           "AccessDenied",
  1242  		Description:    "No AWSAccessKey was presented",
  1243  		HTTPStatusCode: http.StatusForbidden,
  1244  	},
  1245  	ErrInvalidToken: {
  1246  		Code:           "InvalidTokenId",
  1247  		Description:    "The security token included in the request is invalid",
  1248  		HTTPStatusCode: http.StatusForbidden,
  1249  	},
  1250  
  1251  	// S3 extensions.
  1252  	ErrContentSHA256Mismatch: {
  1253  		Code:           "XAmzContentSHA256Mismatch",
  1254  		Description:    "The provided 'x-amz-content-sha256' header does not match what was computed.",
  1255  		HTTPStatusCode: http.StatusBadRequest,
  1256  	},
  1257  	ErrContentChecksumMismatch: {
  1258  		Code:           "XAmzContentChecksumMismatch",
  1259  		Description:    "The provided 'x-amz-checksum' header does not match what was computed.",
  1260  		HTTPStatusCode: http.StatusBadRequest,
  1261  	},
  1262  
  1263  	// MinIO extensions.
  1264  	ErrStorageFull: {
  1265  		Code:           "XMinioStorageFull",
  1266  		Description:    "Storage backend has reached its minimum free drive threshold. Please delete a few objects to proceed.",
  1267  		HTTPStatusCode: http.StatusInsufficientStorage,
  1268  	},
  1269  	ErrRequestBodyParse: {
  1270  		Code:           "XMinioRequestBodyParse",
  1271  		Description:    "The request body failed to parse.",
  1272  		HTTPStatusCode: http.StatusBadRequest,
  1273  	},
  1274  	ErrObjectExistsAsDirectory: {
  1275  		Code:           "XMinioObjectExistsAsDirectory",
  1276  		Description:    "Object name already exists as a directory.",
  1277  		HTTPStatusCode: http.StatusBadRequest,
  1278  	},
  1279  	ErrInvalidObjectName: {
  1280  		Code:           "XMinioInvalidObjectName",
  1281  		Description:    "Object name contains unsupported characters.",
  1282  		HTTPStatusCode: http.StatusBadRequest,
  1283  	},
  1284  	ErrInvalidObjectNamePrefixSlash: {
  1285  		Code:           "XMinioInvalidObjectName",
  1286  		Description:    "Object name contains a leading slash.",
  1287  		HTTPStatusCode: http.StatusBadRequest,
  1288  	},
  1289  	ErrInvalidResourceName: {
  1290  		Code:           "XMinioInvalidResourceName",
  1291  		Description:    "Resource name contains bad components such as \"..\" or \".\".",
  1292  		HTTPStatusCode: http.StatusBadRequest,
  1293  	},
  1294  	ErrServerNotInitialized: {
  1295  		Code:           "XMinioServerNotInitialized",
  1296  		Description:    "Server not initialized, please try again.",
  1297  		HTTPStatusCode: http.StatusServiceUnavailable,
  1298  	},
  1299  	ErrMalformedJSON: {
  1300  		Code:           "XMinioMalformedJSON",
  1301  		Description:    "The JSON you provided was not well-formed or did not validate against our published format.",
  1302  		HTTPStatusCode: http.StatusBadRequest,
  1303  	},
  1304  	ErrInvalidLifecycleQueryParameter: {
  1305  		Code:           "XMinioInvalidLifecycleParameter",
  1306  		Description:    "The boolean value provided for withUpdatedAt query parameter was invalid.",
  1307  		HTTPStatusCode: http.StatusBadRequest,
  1308  	},
  1309  	ErrAdminNoSuchUser: {
  1310  		Code:           "XMinioAdminNoSuchUser",
  1311  		Description:    "The specified user does not exist.",
  1312  		HTTPStatusCode: http.StatusNotFound,
  1313  	},
  1314  	ErrAdminNoSuchUserLDAPWarn: {
  1315  		Code:           "XMinioAdminNoSuchUser",
  1316  		Description:    "The specified user does not exist. If you meant a user in LDAP, use `mc idp ldap`",
  1317  		HTTPStatusCode: http.StatusNotFound,
  1318  	},
  1319  	ErrAdminNoSuchGroup: {
  1320  		Code:           "XMinioAdminNoSuchGroup",
  1321  		Description:    "The specified group does not exist.",
  1322  		HTTPStatusCode: http.StatusNotFound,
  1323  	},
  1324  	ErrAdminNoSuchJob: {
  1325  		Code:           "XMinioAdminNoSuchJob",
  1326  		Description:    "The specified job does not exist.",
  1327  		HTTPStatusCode: http.StatusNotFound,
  1328  	},
  1329  	ErrAdminGroupNotEmpty: {
  1330  		Code:           "XMinioAdminGroupNotEmpty",
  1331  		Description:    "The specified group is not empty - cannot remove it.",
  1332  		HTTPStatusCode: http.StatusBadRequest,
  1333  	},
  1334  	ErrAdminGroupDisabled: {
  1335  		Code:           "XMinioAdminGroupDisabled",
  1336  		Description:    "The specified group is disabled.",
  1337  		HTTPStatusCode: http.StatusBadRequest,
  1338  	},
  1339  	ErrAdminNoSuchPolicy: {
  1340  		Code:           "XMinioAdminNoSuchPolicy",
  1341  		Description:    "The canned policy does not exist.",
  1342  		HTTPStatusCode: http.StatusNotFound,
  1343  	},
  1344  	ErrAdminPolicyChangeAlreadyApplied: {
  1345  		Code:           "XMinioAdminPolicyChangeAlreadyApplied",
  1346  		Description:    "The specified policy change is already in effect.",
  1347  		HTTPStatusCode: http.StatusBadRequest,
  1348  	},
  1349  
  1350  	ErrAdminInvalidArgument: {
  1351  		Code:           "XMinioAdminInvalidArgument",
  1352  		Description:    "Invalid arguments specified.",
  1353  		HTTPStatusCode: http.StatusBadRequest,
  1354  	},
  1355  	ErrAdminInvalidAccessKey: {
  1356  		Code:           "XMinioAdminInvalidAccessKey",
  1357  		Description:    "The access key is invalid.",
  1358  		HTTPStatusCode: http.StatusBadRequest,
  1359  	},
  1360  	ErrAdminInvalidSecretKey: {
  1361  		Code:           "XMinioAdminInvalidSecretKey",
  1362  		Description:    "The secret key is invalid.",
  1363  		HTTPStatusCode: http.StatusBadRequest,
  1364  	},
  1365  	ErrAdminNoAccessKey: {
  1366  		Code:           "XMinioAdminNoAccessKey",
  1367  		Description:    "No access key was provided.",
  1368  		HTTPStatusCode: http.StatusBadRequest,
  1369  	},
  1370  	ErrAdminNoSecretKey: {
  1371  		Code:           "XMinioAdminNoSecretKey",
  1372  		Description:    "No secret key was provided.",
  1373  		HTTPStatusCode: http.StatusBadRequest,
  1374  	},
  1375  	ErrAdminConfigNoQuorum: {
  1376  		Code:           "XMinioAdminConfigNoQuorum",
  1377  		Description:    "Configuration update failed because server quorum was not met",
  1378  		HTTPStatusCode: http.StatusServiceUnavailable,
  1379  	},
  1380  	ErrAdminConfigTooLarge: {
  1381  		Code: "XMinioAdminConfigTooLarge",
  1382  		Description: fmt.Sprintf("Configuration data provided exceeds the allowed maximum of %d bytes",
  1383  			maxEConfigJSONSize),
  1384  		HTTPStatusCode: http.StatusBadRequest,
  1385  	},
  1386  	ErrAdminNoSuchConfigTarget: {
  1387  		Code:           "XMinioAdminNoSuchConfigTarget",
  1388  		Description:    "No such named configuration target exists",
  1389  		HTTPStatusCode: http.StatusBadRequest,
  1390  	},
  1391  	ErrAdminConfigBadJSON: {
  1392  		Code:           "XMinioAdminConfigBadJSON",
  1393  		Description:    "JSON configuration provided is of incorrect format",
  1394  		HTTPStatusCode: http.StatusBadRequest,
  1395  	},
  1396  	ErrAdminConfigEnvOverridden: {
  1397  		Code:           "XMinioAdminConfigEnvOverridden",
  1398  		Description:    "Unable to update config via Admin API due to environment variable override",
  1399  		HTTPStatusCode: http.StatusBadRequest,
  1400  	},
  1401  	ErrAdminConfigDuplicateKeys: {
  1402  		Code:           "XMinioAdminConfigDuplicateKeys",
  1403  		Description:    "JSON configuration provided has objects with duplicate keys",
  1404  		HTTPStatusCode: http.StatusBadRequest,
  1405  	},
  1406  	ErrAdminConfigInvalidIDPType: {
  1407  		Code:           "XMinioAdminConfigInvalidIDPType",
  1408  		Description:    fmt.Sprintf("Invalid IDP configuration type - must be one of %v", madmin.ValidIDPConfigTypes),
  1409  		HTTPStatusCode: http.StatusBadRequest,
  1410  	},
  1411  	ErrAdminConfigLDAPNonDefaultConfigName: {
  1412  		Code:           "XMinioAdminConfigLDAPNonDefaultConfigName",
  1413  		Description:    "Only a single LDAP configuration is supported - config name must be empty or `_`",
  1414  		HTTPStatusCode: http.StatusBadRequest,
  1415  	},
  1416  	ErrAdminConfigLDAPValidation: {
  1417  		Code:           "XMinioAdminConfigLDAPValidation",
  1418  		Description:    "LDAP Configuration validation failed",
  1419  		HTTPStatusCode: http.StatusBadRequest,
  1420  	},
  1421  	ErrAdminConfigIDPCfgNameAlreadyExists: {
  1422  		Code:           "XMinioAdminConfigIDPCfgNameAlreadyExists",
  1423  		Description:    "An IDP configuration with the given name already exists",
  1424  		HTTPStatusCode: http.StatusBadRequest,
  1425  	},
  1426  	ErrAdminConfigIDPCfgNameDoesNotExist: {
  1427  		Code:           "XMinioAdminConfigIDPCfgNameDoesNotExist",
  1428  		Description:    "No such IDP configuration exists",
  1429  		HTTPStatusCode: http.StatusBadRequest,
  1430  	},
  1431  	ErrAdminConfigNotificationTargetsFailed: {
  1432  		Code:           "XMinioAdminNotificationTargetsTestFailed",
  1433  		Description:    "Configuration update failed due an unsuccessful attempt to connect to one or more notification servers",
  1434  		HTTPStatusCode: http.StatusBadRequest,
  1435  	},
  1436  	ErrAdminProfilerNotEnabled: {
  1437  		Code:           "XMinioAdminProfilerNotEnabled",
  1438  		Description:    "Unable to perform the requested operation because profiling is not enabled",
  1439  		HTTPStatusCode: http.StatusBadRequest,
  1440  	},
  1441  	ErrAdminBucketQuotaExceeded: {
  1442  		Code:           "XMinioAdminBucketQuotaExceeded",
  1443  		Description:    "Bucket quota exceeded",
  1444  		HTTPStatusCode: http.StatusBadRequest,
  1445  	},
  1446  	ErrAdminNoSuchQuotaConfiguration: {
  1447  		Code:           "XMinioAdminNoSuchQuotaConfiguration",
  1448  		Description:    "The quota configuration does not exist",
  1449  		HTTPStatusCode: http.StatusNotFound,
  1450  	},
  1451  	ErrInsecureClientRequest: {
  1452  		Code:           "XMinioInsecureClientRequest",
  1453  		Description:    "Cannot respond to plain-text request from TLS-encrypted server",
  1454  		HTTPStatusCode: http.StatusBadRequest,
  1455  	},
  1456  	ErrRequestTimedout: {
  1457  		Code:           "RequestTimeout",
  1458  		Description:    "A timeout occurred while trying to lock a resource, please reduce your request rate",
  1459  		HTTPStatusCode: http.StatusServiceUnavailable,
  1460  	},
  1461  	ErrClientDisconnected: {
  1462  		Code:           "ClientDisconnected",
  1463  		Description:    "Client disconnected before response was ready",
  1464  		HTTPStatusCode: 499, // No official code, use nginx value.
  1465  	},
  1466  	ErrTooManyRequests: {
  1467  		Code:           "TooManyRequests",
  1468  		Description:    "Deadline exceeded while waiting in incoming queue, please reduce your request rate",
  1469  		HTTPStatusCode: http.StatusServiceUnavailable,
  1470  	},
  1471  	ErrUnsupportedMetadata: {
  1472  		Code:           "InvalidArgument",
  1473  		Description:    "Your metadata headers are not supported.",
  1474  		HTTPStatusCode: http.StatusBadRequest,
  1475  	},
  1476  	ErrUnsupportedHostHeader: {
  1477  		Code:           "InvalidArgument",
  1478  		Description:    "Your Host header is malformed.",
  1479  		HTTPStatusCode: http.StatusBadRequest,
  1480  	},
  1481  	ErrObjectTampered: {
  1482  		Code:           "XMinioObjectTampered",
  1483  		Description:    errObjectTampered.Error(),
  1484  		HTTPStatusCode: http.StatusPartialContent,
  1485  	},
  1486  
  1487  	ErrSiteReplicationInvalidRequest: {
  1488  		Code:           "XMinioSiteReplicationInvalidRequest",
  1489  		Description:    "Invalid site-replication request",
  1490  		HTTPStatusCode: http.StatusBadRequest,
  1491  	},
  1492  	ErrSiteReplicationPeerResp: {
  1493  		Code:           "XMinioSiteReplicationPeerResp",
  1494  		Description:    "Error received when contacting a peer site",
  1495  		HTTPStatusCode: http.StatusBadRequest,
  1496  	},
  1497  	ErrSiteReplicationBackendIssue: {
  1498  		Code:           "XMinioSiteReplicationBackendIssue",
  1499  		Description:    "Error when requesting object layer backend",
  1500  		HTTPStatusCode: http.StatusServiceUnavailable,
  1501  	},
  1502  	ErrSiteReplicationServiceAccountError: {
  1503  		Code:           "XMinioSiteReplicationServiceAccountError",
  1504  		Description:    "Site replication related service account error",
  1505  		HTTPStatusCode: http.StatusServiceUnavailable,
  1506  	},
  1507  	ErrSiteReplicationBucketConfigError: {
  1508  		Code:           "XMinioSiteReplicationBucketConfigError",
  1509  		Description:    "Error while configuring replication on a bucket",
  1510  		HTTPStatusCode: http.StatusServiceUnavailable,
  1511  	},
  1512  	ErrSiteReplicationBucketMetaError: {
  1513  		Code:           "XMinioSiteReplicationBucketMetaError",
  1514  		Description:    "Error while replicating bucket metadata",
  1515  		HTTPStatusCode: http.StatusServiceUnavailable,
  1516  	},
  1517  	ErrSiteReplicationIAMError: {
  1518  		Code:           "XMinioSiteReplicationIAMError",
  1519  		Description:    "Error while replicating an IAM item",
  1520  		HTTPStatusCode: http.StatusServiceUnavailable,
  1521  	},
  1522  	ErrSiteReplicationConfigMissing: {
  1523  		Code:           "XMinioSiteReplicationConfigMissingError",
  1524  		Description:    "Site not found in site replication configuration",
  1525  		HTTPStatusCode: http.StatusBadRequest,
  1526  	},
  1527  	ErrSiteReplicationIAMConfigMismatch: {
  1528  		Code:           "XMinioSiteReplicationIAMConfigMismatch",
  1529  		Description:    "IAM configuration mismatch between sites",
  1530  		HTTPStatusCode: http.StatusBadRequest,
  1531  	},
  1532  	ErrAdminRebalanceAlreadyStarted: {
  1533  		Code:           "XMinioAdminRebalanceAlreadyStarted",
  1534  		Description:    "Pool rebalance is already started",
  1535  		HTTPStatusCode: http.StatusConflict,
  1536  	},
  1537  	ErrAdminRebalanceNotStarted: {
  1538  		Code:           "XMinioAdminRebalanceNotStarted",
  1539  		Description:    "Pool rebalance is not started",
  1540  		HTTPStatusCode: http.StatusNotFound,
  1541  	},
  1542  	ErrMaximumExpires: {
  1543  		Code:           "AuthorizationQueryParametersError",
  1544  		Description:    "X-Amz-Expires must be less than a week (in seconds); that is, the given X-Amz-Expires must be less than 604800 seconds",
  1545  		HTTPStatusCode: http.StatusBadRequest,
  1546  	},
  1547  
  1548  	// Generic Invalid-Request error. Should be used for response errors only for unlikely
  1549  	// corner case errors for which introducing new APIErrorCode is not worth it. LogIf()
  1550  	// should be used to log the error at the source of the error for debugging purposes.
  1551  	ErrInvalidRequest: {
  1552  		Code:           "InvalidRequest",
  1553  		Description:    "Invalid Request",
  1554  		HTTPStatusCode: http.StatusBadRequest,
  1555  	},
  1556  	ErrHealNotImplemented: {
  1557  		Code:           "XMinioHealNotImplemented",
  1558  		Description:    "This server does not implement heal functionality.",
  1559  		HTTPStatusCode: http.StatusBadRequest,
  1560  	},
  1561  	ErrHealNoSuchProcess: {
  1562  		Code:           "XMinioHealNoSuchProcess",
  1563  		Description:    "No such heal process is running on the server",
  1564  		HTTPStatusCode: http.StatusBadRequest,
  1565  	},
  1566  	ErrHealInvalidClientToken: {
  1567  		Code:           "XMinioHealInvalidClientToken",
  1568  		Description:    "Client token mismatch",
  1569  		HTTPStatusCode: http.StatusBadRequest,
  1570  	},
  1571  	ErrHealMissingBucket: {
  1572  		Code:           "XMinioHealMissingBucket",
  1573  		Description:    "A heal start request with a non-empty object-prefix parameter requires a bucket to be specified.",
  1574  		HTTPStatusCode: http.StatusBadRequest,
  1575  	},
  1576  	ErrHealAlreadyRunning: {
  1577  		Code:           "XMinioHealAlreadyRunning",
  1578  		Description:    "",
  1579  		HTTPStatusCode: http.StatusBadRequest,
  1580  	},
  1581  	ErrHealOverlappingPaths: {
  1582  		Code:           "XMinioHealOverlappingPaths",
  1583  		Description:    "",
  1584  		HTTPStatusCode: http.StatusBadRequest,
  1585  	},
  1586  	ErrBackendDown: {
  1587  		Code:           "XMinioBackendDown",
  1588  		Description:    "Remote backend is unreachable",
  1589  		HTTPStatusCode: http.StatusBadRequest,
  1590  	},
  1591  	ErrIncorrectContinuationToken: {
  1592  		Code:           "InvalidArgument",
  1593  		Description:    "The continuation token provided is incorrect",
  1594  		HTTPStatusCode: http.StatusBadRequest,
  1595  	},
  1596  	// S3 Select API Errors
  1597  	ErrEmptyRequestBody: {
  1598  		Code:           "EmptyRequestBody",
  1599  		Description:    "Request body cannot be empty.",
  1600  		HTTPStatusCode: http.StatusBadRequest,
  1601  	},
  1602  	ErrUnsupportedFunction: {
  1603  		Code:           "UnsupportedFunction",
  1604  		Description:    "Encountered an unsupported SQL function.",
  1605  		HTTPStatusCode: http.StatusBadRequest,
  1606  	},
  1607  	ErrInvalidDataSource: {
  1608  		Code:           "InvalidDataSource",
  1609  		Description:    "Invalid data source type. Only CSV and JSON are supported at this time.",
  1610  		HTTPStatusCode: http.StatusBadRequest,
  1611  	},
  1612  	ErrInvalidExpressionType: {
  1613  		Code:           "InvalidExpressionType",
  1614  		Description:    "The ExpressionType is invalid. Only SQL expressions are supported at this time.",
  1615  		HTTPStatusCode: http.StatusBadRequest,
  1616  	},
  1617  	ErrBusy: {
  1618  		Code:           "ServerBusy",
  1619  		Description:    "The service is unavailable. Please retry.",
  1620  		HTTPStatusCode: http.StatusServiceUnavailable,
  1621  	},
  1622  	ErrUnauthorizedAccess: {
  1623  		Code:           "UnauthorizedAccess",
  1624  		Description:    "You are not authorized to perform this operation",
  1625  		HTTPStatusCode: http.StatusUnauthorized,
  1626  	},
  1627  	ErrExpressionTooLong: {
  1628  		Code:           "ExpressionTooLong",
  1629  		Description:    "The SQL expression is too long: The maximum byte-length for the SQL expression is 256 KB.",
  1630  		HTTPStatusCode: http.StatusBadRequest,
  1631  	},
  1632  	ErrIllegalSQLFunctionArgument: {
  1633  		Code:           "IllegalSqlFunctionArgument",
  1634  		Description:    "Illegal argument was used in the SQL function.",
  1635  		HTTPStatusCode: http.StatusBadRequest,
  1636  	},
  1637  	ErrInvalidKeyPath: {
  1638  		Code:           "InvalidKeyPath",
  1639  		Description:    "Key path in the SQL expression is invalid.",
  1640  		HTTPStatusCode: http.StatusBadRequest,
  1641  	},
  1642  	ErrInvalidCompressionFormat: {
  1643  		Code:           "InvalidCompressionFormat",
  1644  		Description:    "The file is not in a supported compression format. Only GZIP is supported at this time.",
  1645  		HTTPStatusCode: http.StatusBadRequest,
  1646  	},
  1647  	ErrInvalidFileHeaderInfo: {
  1648  		Code:           "InvalidFileHeaderInfo",
  1649  		Description:    "The FileHeaderInfo is invalid. Only NONE, USE, and IGNORE are supported.",
  1650  		HTTPStatusCode: http.StatusBadRequest,
  1651  	},
  1652  	ErrInvalidJSONType: {
  1653  		Code:           "InvalidJsonType",
  1654  		Description:    "The JsonType is invalid. Only DOCUMENT and LINES are supported at this time.",
  1655  		HTTPStatusCode: http.StatusBadRequest,
  1656  	},
  1657  	ErrInvalidQuoteFields: {
  1658  		Code:           "InvalidQuoteFields",
  1659  		Description:    "The QuoteFields is invalid. Only ALWAYS and ASNEEDED are supported.",
  1660  		HTTPStatusCode: http.StatusBadRequest,
  1661  	},
  1662  	ErrInvalidRequestParameter: {
  1663  		Code:           "InvalidRequestParameter",
  1664  		Description:    "The value of a parameter in SelectRequest element is invalid. Check the service API documentation and try again.",
  1665  		HTTPStatusCode: http.StatusBadRequest,
  1666  	},
  1667  	ErrInvalidDataType: {
  1668  		Code:           "InvalidDataType",
  1669  		Description:    "The SQL expression contains an invalid data type.",
  1670  		HTTPStatusCode: http.StatusBadRequest,
  1671  	},
  1672  	ErrInvalidTextEncoding: {
  1673  		Code:           "InvalidTextEncoding",
  1674  		Description:    "Invalid encoding type. Only UTF-8 encoding is supported at this time.",
  1675  		HTTPStatusCode: http.StatusBadRequest,
  1676  	},
  1677  	ErrInvalidTableAlias: {
  1678  		Code:           "InvalidTableAlias",
  1679  		Description:    "The SQL expression contains an invalid table alias.",
  1680  		HTTPStatusCode: http.StatusBadRequest,
  1681  	},
  1682  	ErrMissingRequiredParameter: {
  1683  		Code:           "MissingRequiredParameter",
  1684  		Description:    "The SelectRequest entity is missing a required parameter. Check the service documentation and try again.",
  1685  		HTTPStatusCode: http.StatusBadRequest,
  1686  	},
  1687  	ErrObjectSerializationConflict: {
  1688  		Code:           "ObjectSerializationConflict",
  1689  		Description:    "The SelectRequest entity can only contain one of CSV or JSON. Check the service documentation and try again.",
  1690  		HTTPStatusCode: http.StatusBadRequest,
  1691  	},
  1692  	ErrUnsupportedSQLOperation: {
  1693  		Code:           "UnsupportedSqlOperation",
  1694  		Description:    "Encountered an unsupported SQL operation.",
  1695  		HTTPStatusCode: http.StatusBadRequest,
  1696  	},
  1697  	ErrUnsupportedSQLStructure: {
  1698  		Code:           "UnsupportedSqlStructure",
  1699  		Description:    "Encountered an unsupported SQL structure. Check the SQL Reference.",
  1700  		HTTPStatusCode: http.StatusBadRequest,
  1701  	},
  1702  	ErrUnsupportedSyntax: {
  1703  		Code:           "UnsupportedSyntax",
  1704  		Description:    "Encountered invalid syntax.",
  1705  		HTTPStatusCode: http.StatusBadRequest,
  1706  	},
  1707  	ErrUnsupportedRangeHeader: {
  1708  		Code:           "UnsupportedRangeHeader",
  1709  		Description:    "Range header is not supported for this operation.",
  1710  		HTTPStatusCode: http.StatusBadRequest,
  1711  	},
  1712  	ErrLexerInvalidChar: {
  1713  		Code:           "LexerInvalidChar",
  1714  		Description:    "The SQL expression contains an invalid character.",
  1715  		HTTPStatusCode: http.StatusBadRequest,
  1716  	},
  1717  	ErrLexerInvalidOperator: {
  1718  		Code:           "LexerInvalidOperator",
  1719  		Description:    "The SQL expression contains an invalid literal.",
  1720  		HTTPStatusCode: http.StatusBadRequest,
  1721  	},
  1722  	ErrLexerInvalidLiteral: {
  1723  		Code:           "LexerInvalidLiteral",
  1724  		Description:    "The SQL expression contains an invalid operator.",
  1725  		HTTPStatusCode: http.StatusBadRequest,
  1726  	},
  1727  	ErrLexerInvalidIONLiteral: {
  1728  		Code:           "LexerInvalidIONLiteral",
  1729  		Description:    "The SQL expression contains an invalid operator.",
  1730  		HTTPStatusCode: http.StatusBadRequest,
  1731  	},
  1732  	ErrParseExpectedDatePart: {
  1733  		Code:           "ParseExpectedDatePart",
  1734  		Description:    "Did not find the expected date part in the SQL expression.",
  1735  		HTTPStatusCode: http.StatusBadRequest,
  1736  	},
  1737  	ErrParseExpectedKeyword: {
  1738  		Code:           "ParseExpectedKeyword",
  1739  		Description:    "Did not find the expected keyword in the SQL expression.",
  1740  		HTTPStatusCode: http.StatusBadRequest,
  1741  	},
  1742  	ErrParseExpectedTokenType: {
  1743  		Code:           "ParseExpectedTokenType",
  1744  		Description:    "Did not find the expected token in the SQL expression.",
  1745  		HTTPStatusCode: http.StatusBadRequest,
  1746  	},
  1747  	ErrParseExpected2TokenTypes: {
  1748  		Code:           "ParseExpected2TokenTypes",
  1749  		Description:    "Did not find the expected token in the SQL expression.",
  1750  		HTTPStatusCode: http.StatusBadRequest,
  1751  	},
  1752  	ErrParseExpectedNumber: {
  1753  		Code:           "ParseExpectedNumber",
  1754  		Description:    "Did not find the expected number in the SQL expression.",
  1755  		HTTPStatusCode: http.StatusBadRequest,
  1756  	},
  1757  	ErrParseExpectedRightParenBuiltinFunctionCall: {
  1758  		Code:           "ParseExpectedRightParenBuiltinFunctionCall",
  1759  		Description:    "Did not find the expected right parenthesis character in the SQL expression.",
  1760  		HTTPStatusCode: http.StatusBadRequest,
  1761  	},
  1762  	ErrParseExpectedTypeName: {
  1763  		Code:           "ParseExpectedTypeName",
  1764  		Description:    "Did not find the expected type name in the SQL expression.",
  1765  		HTTPStatusCode: http.StatusBadRequest,
  1766  	},
  1767  	ErrParseExpectedWhenClause: {
  1768  		Code:           "ParseExpectedWhenClause",
  1769  		Description:    "Did not find the expected WHEN clause in the SQL expression. CASE is not supported.",
  1770  		HTTPStatusCode: http.StatusBadRequest,
  1771  	},
  1772  	ErrParseUnsupportedToken: {
  1773  		Code:           "ParseUnsupportedToken",
  1774  		Description:    "The SQL expression contains an unsupported token.",
  1775  		HTTPStatusCode: http.StatusBadRequest,
  1776  	},
  1777  	ErrParseUnsupportedLiteralsGroupBy: {
  1778  		Code:           "ParseUnsupportedLiteralsGroupBy",
  1779  		Description:    "The SQL expression contains an unsupported use of GROUP BY.",
  1780  		HTTPStatusCode: http.StatusBadRequest,
  1781  	},
  1782  	ErrParseExpectedMember: {
  1783  		Code:           "ParseExpectedMember",
  1784  		Description:    "The SQL expression contains an unsupported use of MEMBER.",
  1785  		HTTPStatusCode: http.StatusBadRequest,
  1786  	},
  1787  	ErrParseUnsupportedSelect: {
  1788  		Code:           "ParseUnsupportedSelect",
  1789  		Description:    "The SQL expression contains an unsupported use of SELECT.",
  1790  		HTTPStatusCode: http.StatusBadRequest,
  1791  	},
  1792  	ErrParseUnsupportedCase: {
  1793  		Code:           "ParseUnsupportedCase",
  1794  		Description:    "The SQL expression contains an unsupported use of CASE.",
  1795  		HTTPStatusCode: http.StatusBadRequest,
  1796  	},
  1797  	ErrParseUnsupportedCaseClause: {
  1798  		Code:           "ParseUnsupportedCaseClause",
  1799  		Description:    "The SQL expression contains an unsupported use of CASE.",
  1800  		HTTPStatusCode: http.StatusBadRequest,
  1801  	},
  1802  	ErrParseUnsupportedAlias: {
  1803  		Code:           "ParseUnsupportedAlias",
  1804  		Description:    "The SQL expression contains an unsupported use of ALIAS.",
  1805  		HTTPStatusCode: http.StatusBadRequest,
  1806  	},
  1807  	ErrParseUnsupportedSyntax: {
  1808  		Code:           "ParseUnsupportedSyntax",
  1809  		Description:    "The SQL expression contains unsupported syntax.",
  1810  		HTTPStatusCode: http.StatusBadRequest,
  1811  	},
  1812  	ErrParseUnknownOperator: {
  1813  		Code:           "ParseUnknownOperator",
  1814  		Description:    "The SQL expression contains an invalid operator.",
  1815  		HTTPStatusCode: http.StatusBadRequest,
  1816  	},
  1817  	ErrParseMissingIdentAfterAt: {
  1818  		Code:           "ParseMissingIdentAfterAt",
  1819  		Description:    "Did not find the expected identifier after the @ symbol in the SQL expression.",
  1820  		HTTPStatusCode: http.StatusBadRequest,
  1821  	},
  1822  	ErrParseUnexpectedOperator: {
  1823  		Code:           "ParseUnexpectedOperator",
  1824  		Description:    "The SQL expression contains an unexpected operator.",
  1825  		HTTPStatusCode: http.StatusBadRequest,
  1826  	},
  1827  	ErrParseUnexpectedTerm: {
  1828  		Code:           "ParseUnexpectedTerm",
  1829  		Description:    "The SQL expression contains an unexpected term.",
  1830  		HTTPStatusCode: http.StatusBadRequest,
  1831  	},
  1832  	ErrParseUnexpectedToken: {
  1833  		Code:           "ParseUnexpectedToken",
  1834  		Description:    "The SQL expression contains an unexpected token.",
  1835  		HTTPStatusCode: http.StatusBadRequest,
  1836  	},
  1837  	ErrParseUnexpectedKeyword: {
  1838  		Code:           "ParseUnexpectedKeyword",
  1839  		Description:    "The SQL expression contains an unexpected keyword.",
  1840  		HTTPStatusCode: http.StatusBadRequest,
  1841  	},
  1842  	ErrParseExpectedExpression: {
  1843  		Code:           "ParseExpectedExpression",
  1844  		Description:    "Did not find the expected SQL expression.",
  1845  		HTTPStatusCode: http.StatusBadRequest,
  1846  	},
  1847  	ErrParseExpectedLeftParenAfterCast: {
  1848  		Code:           "ParseExpectedLeftParenAfterCast",
  1849  		Description:    "Did not find expected the left parenthesis in the SQL expression.",
  1850  		HTTPStatusCode: http.StatusBadRequest,
  1851  	},
  1852  	ErrParseExpectedLeftParenValueConstructor: {
  1853  		Code:           "ParseExpectedLeftParenValueConstructor",
  1854  		Description:    "Did not find expected the left parenthesis in the SQL expression.",
  1855  		HTTPStatusCode: http.StatusBadRequest,
  1856  	},
  1857  	ErrParseExpectedLeftParenBuiltinFunctionCall: {
  1858  		Code:           "ParseExpectedLeftParenBuiltinFunctionCall",
  1859  		Description:    "Did not find the expected left parenthesis in the SQL expression.",
  1860  		HTTPStatusCode: http.StatusBadRequest,
  1861  	},
  1862  	ErrParseExpectedArgumentDelimiter: {
  1863  		Code:           "ParseExpectedArgumentDelimiter",
  1864  		Description:    "Did not find the expected argument delimiter in the SQL expression.",
  1865  		HTTPStatusCode: http.StatusBadRequest,
  1866  	},
  1867  	ErrParseCastArity: {
  1868  		Code:           "ParseCastArity",
  1869  		Description:    "The SQL expression CAST has incorrect arity.",
  1870  		HTTPStatusCode: http.StatusBadRequest,
  1871  	},
  1872  	ErrParseInvalidTypeParam: {
  1873  		Code:           "ParseInvalidTypeParam",
  1874  		Description:    "The SQL expression contains an invalid parameter value.",
  1875  		HTTPStatusCode: http.StatusBadRequest,
  1876  	},
  1877  	ErrParseEmptySelect: {
  1878  		Code:           "ParseEmptySelect",
  1879  		Description:    "The SQL expression contains an empty SELECT.",
  1880  		HTTPStatusCode: http.StatusBadRequest,
  1881  	},
  1882  	ErrParseSelectMissingFrom: {
  1883  		Code:           "ParseSelectMissingFrom",
  1884  		Description:    "GROUP is not supported in the SQL expression.",
  1885  		HTTPStatusCode: http.StatusBadRequest,
  1886  	},
  1887  	ErrParseExpectedIdentForGroupName: {
  1888  		Code:           "ParseExpectedIdentForGroupName",
  1889  		Description:    "GROUP is not supported in the SQL expression.",
  1890  		HTTPStatusCode: http.StatusBadRequest,
  1891  	},
  1892  	ErrParseExpectedIdentForAlias: {
  1893  		Code:           "ParseExpectedIdentForAlias",
  1894  		Description:    "Did not find the expected identifier for the alias in the SQL expression.",
  1895  		HTTPStatusCode: http.StatusBadRequest,
  1896  	},
  1897  	ErrParseUnsupportedCallWithStar: {
  1898  		Code:           "ParseUnsupportedCallWithStar",
  1899  		Description:    "Only COUNT with (*) as a parameter is supported in the SQL expression.",
  1900  		HTTPStatusCode: http.StatusBadRequest,
  1901  	},
  1902  	ErrParseNonUnaryAggregateFunctionCall: {
  1903  		Code:           "ParseNonUnaryAggregateFunctionCall",
  1904  		Description:    "Only one argument is supported for aggregate functions in the SQL expression.",
  1905  		HTTPStatusCode: http.StatusBadRequest,
  1906  	},
  1907  	ErrParseMalformedJoin: {
  1908  		Code:           "ParseMalformedJoin",
  1909  		Description:    "JOIN is not supported in the SQL expression.",
  1910  		HTTPStatusCode: http.StatusBadRequest,
  1911  	},
  1912  	ErrParseExpectedIdentForAt: {
  1913  		Code:           "ParseExpectedIdentForAt",
  1914  		Description:    "Did not find the expected identifier for AT name in the SQL expression.",
  1915  		HTTPStatusCode: http.StatusBadRequest,
  1916  	},
  1917  	ErrParseAsteriskIsNotAloneInSelectList: {
  1918  		Code:           "ParseAsteriskIsNotAloneInSelectList",
  1919  		Description:    "Other expressions are not allowed in the SELECT list when '*' is used without dot notation in the SQL expression.",
  1920  		HTTPStatusCode: http.StatusBadRequest,
  1921  	},
  1922  	ErrParseCannotMixSqbAndWildcardInSelectList: {
  1923  		Code:           "ParseCannotMixSqbAndWildcardInSelectList",
  1924  		Description:    "Cannot mix [] and * in the same expression in a SELECT list in SQL expression.",
  1925  		HTTPStatusCode: http.StatusBadRequest,
  1926  	},
  1927  	ErrParseInvalidContextForWildcardInSelectList: {
  1928  		Code:           "ParseInvalidContextForWildcardInSelectList",
  1929  		Description:    "Invalid use of * in SELECT list in the SQL expression.",
  1930  		HTTPStatusCode: http.StatusBadRequest,
  1931  	},
  1932  	ErrIncorrectSQLFunctionArgumentType: {
  1933  		Code:           "IncorrectSqlFunctionArgumentType",
  1934  		Description:    "Incorrect type of arguments in function call in the SQL expression.",
  1935  		HTTPStatusCode: http.StatusBadRequest,
  1936  	},
  1937  	ErrValueParseFailure: {
  1938  		Code:           "ValueParseFailure",
  1939  		Description:    "Time stamp parse failure in the SQL expression.",
  1940  		HTTPStatusCode: http.StatusBadRequest,
  1941  	},
  1942  	ErrEvaluatorInvalidArguments: {
  1943  		Code:           "EvaluatorInvalidArguments",
  1944  		Description:    "Incorrect number of arguments in the function call in the SQL expression.",
  1945  		HTTPStatusCode: http.StatusBadRequest,
  1946  	},
  1947  	ErrIntegerOverflow: {
  1948  		Code:           "IntegerOverflow",
  1949  		Description:    "Int overflow or underflow in the SQL expression.",
  1950  		HTTPStatusCode: http.StatusBadRequest,
  1951  	},
  1952  	ErrLikeInvalidInputs: {
  1953  		Code:           "LikeInvalidInputs",
  1954  		Description:    "Invalid argument given to the LIKE clause in the SQL expression.",
  1955  		HTTPStatusCode: http.StatusBadRequest,
  1956  	},
  1957  	ErrCastFailed: {
  1958  		Code:           "CastFailed",
  1959  		Description:    "Attempt to convert from one data type to another using CAST failed in the SQL expression.",
  1960  		HTTPStatusCode: http.StatusBadRequest,
  1961  	},
  1962  	ErrInvalidCast: {
  1963  		Code:           "InvalidCast",
  1964  		Description:    "Attempt to convert from one data type to another using CAST failed in the SQL expression.",
  1965  		HTTPStatusCode: http.StatusBadRequest,
  1966  	},
  1967  	ErrEvaluatorInvalidTimestampFormatPattern: {
  1968  		Code:           "EvaluatorInvalidTimestampFormatPattern",
  1969  		Description:    "Time stamp format pattern requires additional fields in the SQL expression.",
  1970  		HTTPStatusCode: http.StatusBadRequest,
  1971  	},
  1972  	ErrEvaluatorInvalidTimestampFormatPatternSymbolForParsing: {
  1973  		Code:           "EvaluatorInvalidTimestampFormatPatternSymbolForParsing",
  1974  		Description:    "Time stamp format pattern contains a valid format symbol that cannot be applied to time stamp parsing in the SQL expression.",
  1975  		HTTPStatusCode: http.StatusBadRequest,
  1976  	},
  1977  	ErrEvaluatorTimestampFormatPatternDuplicateFields: {
  1978  		Code:           "EvaluatorTimestampFormatPatternDuplicateFields",
  1979  		Description:    "Time stamp format pattern contains multiple format specifiers representing the time stamp field in the SQL expression.",
  1980  		HTTPStatusCode: http.StatusBadRequest,
  1981  	},
  1982  	ErrEvaluatorTimestampFormatPatternHourClockAmPmMismatch: {
  1983  		Code:           "EvaluatorUnterminatedTimestampFormatPatternToken",
  1984  		Description:    "Time stamp format pattern contains unterminated token in the SQL expression.",
  1985  		HTTPStatusCode: http.StatusBadRequest,
  1986  	},
  1987  	ErrEvaluatorUnterminatedTimestampFormatPatternToken: {
  1988  		Code:           "EvaluatorInvalidTimestampFormatPatternToken",
  1989  		Description:    "Time stamp format pattern contains an invalid token in the SQL expression.",
  1990  		HTTPStatusCode: http.StatusBadRequest,
  1991  	},
  1992  	ErrEvaluatorInvalidTimestampFormatPatternToken: {
  1993  		Code:           "EvaluatorInvalidTimestampFormatPatternToken",
  1994  		Description:    "Time stamp format pattern contains an invalid token in the SQL expression.",
  1995  		HTTPStatusCode: http.StatusBadRequest,
  1996  	},
  1997  	ErrEvaluatorInvalidTimestampFormatPatternSymbol: {
  1998  		Code:           "EvaluatorInvalidTimestampFormatPatternSymbol",
  1999  		Description:    "Time stamp format pattern contains an invalid symbol in the SQL expression.",
  2000  		HTTPStatusCode: http.StatusBadRequest,
  2001  	},
  2002  	ErrEvaluatorBindingDoesNotExist: {
  2003  		Code:           "ErrEvaluatorBindingDoesNotExist",
  2004  		Description:    "A column name or a path provided does not exist in the SQL expression",
  2005  		HTTPStatusCode: http.StatusBadRequest,
  2006  	},
  2007  	ErrMissingHeaders: {
  2008  		Code:           "MissingHeaders",
  2009  		Description:    "Some headers in the query are missing from the file. Check the file and try again.",
  2010  		HTTPStatusCode: http.StatusBadRequest,
  2011  	},
  2012  	ErrInvalidColumnIndex: {
  2013  		Code:           "InvalidColumnIndex",
  2014  		Description:    "The column index is invalid. Please check the service documentation and try again.",
  2015  		HTTPStatusCode: http.StatusBadRequest,
  2016  	},
  2017  	ErrInvalidDecompressedSize: {
  2018  		Code:           "XMinioInvalidDecompressedSize",
  2019  		Description:    "The data provided is unfit for decompression",
  2020  		HTTPStatusCode: http.StatusBadRequest,
  2021  	},
  2022  	ErrAddUserInvalidArgument: {
  2023  		Code:           "XMinioInvalidIAMCredentials",
  2024  		Description:    "Credential is not allowed to be same as admin access key",
  2025  		HTTPStatusCode: http.StatusForbidden,
  2026  	},
  2027  	ErrAdminResourceInvalidArgument: {
  2028  		Code:           "XMinioInvalidResource",
  2029  		Description:    "Policy, user or group names are not allowed to begin or end with space characters",
  2030  		HTTPStatusCode: http.StatusBadRequest,
  2031  	},
  2032  	ErrAdminAccountNotEligible: {
  2033  		Code:           "XMinioInvalidIAMCredentials",
  2034  		Description:    "The administrator key is not eligible for this operation",
  2035  		HTTPStatusCode: http.StatusForbidden,
  2036  	},
  2037  	ErrAccountNotEligible: {
  2038  		Code:           "XMinioInvalidIAMCredentials",
  2039  		Description:    "The account key is not eligible for this operation",
  2040  		HTTPStatusCode: http.StatusForbidden,
  2041  	},
  2042  	ErrAdminServiceAccountNotFound: {
  2043  		Code:           "XMinioInvalidIAMCredentials",
  2044  		Description:    "The specified service account is not found",
  2045  		HTTPStatusCode: http.StatusNotFound,
  2046  	},
  2047  	ErrPostPolicyConditionInvalidFormat: {
  2048  		Code:           "PostPolicyInvalidKeyName",
  2049  		Description:    "Invalid according to Policy: Policy Condition failed",
  2050  		HTTPStatusCode: http.StatusForbidden,
  2051  	},
  2052  	ErrInvalidChecksum: {
  2053  		Code:           "InvalidArgument",
  2054  		Description:    "Invalid checksum provided.",
  2055  		HTTPStatusCode: http.StatusBadRequest,
  2056  	},
  2057  	ErrLambdaARNInvalid: {
  2058  		Code:           "LambdaARNInvalid",
  2059  		Description:    "The specified lambda ARN is invalid",
  2060  		HTTPStatusCode: http.StatusBadRequest,
  2061  	},
  2062  	ErrLambdaARNNotFound: {
  2063  		Code:           "LambdaARNNotFound",
  2064  		Description:    "The specified lambda ARN does not exist",
  2065  		HTTPStatusCode: http.StatusNotFound,
  2066  	},
  2067  	ErrPolicyAlreadyAttached: {
  2068  		Code:           "XMinioPolicyAlreadyAttached",
  2069  		Description:    "The specified policy is already attached.",
  2070  		HTTPStatusCode: http.StatusConflict,
  2071  	},
  2072  	ErrPolicyNotAttached: {
  2073  		Code:           "XMinioPolicyNotAttached",
  2074  		Description:    "The specified policy is not found.",
  2075  		HTTPStatusCode: http.StatusNotFound,
  2076  	},
  2077  	ErrInvalidAttributeName: {
  2078  		Code:           "InvalidArgument",
  2079  		Description:    "Invalid attribute name specified.",
  2080  		HTTPStatusCode: http.StatusBadRequest,
  2081  	},
  2082  	// Add your error structure here.
  2083  }
  2084  
  2085  // toAPIErrorCode - Converts embedded errors. Convenience
  2086  // function written to handle all cases where we have known types of
  2087  // errors returned by underlying layers.
  2088  func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
  2089  	if err == nil {
  2090  		return ErrNone
  2091  	}
  2092  
  2093  	// Errors that are generated by net.Conn and any context errors must be handled here.
  2094  	if errors.Is(err, os.ErrDeadlineExceeded) || errors.Is(err, context.DeadlineExceeded) {
  2095  		return ErrRequestTimedout
  2096  	}
  2097  
  2098  	// Only return ErrClientDisconnected if the provided context is actually canceled.
  2099  	// This way downstream context.Canceled will still report ErrRequestTimedout
  2100  	if contextCanceled(ctx) && errors.Is(ctx.Err(), context.Canceled) {
  2101  		return ErrClientDisconnected
  2102  	}
  2103  
  2104  	// Unwrap the error first
  2105  	err = unwrapAll(err)
  2106  
  2107  	switch err {
  2108  	case errInvalidArgument:
  2109  		apiErr = ErrAdminInvalidArgument
  2110  	case errNoSuchPolicy:
  2111  		apiErr = ErrAdminNoSuchPolicy
  2112  	case errNoSuchUser:
  2113  		apiErr = ErrAdminNoSuchUser
  2114  	case errNoSuchUserLDAPWarn:
  2115  		apiErr = ErrAdminNoSuchUserLDAPWarn
  2116  	case errNoSuchServiceAccount:
  2117  		apiErr = ErrAdminServiceAccountNotFound
  2118  	case errNoSuchGroup:
  2119  		apiErr = ErrAdminNoSuchGroup
  2120  	case errGroupNotEmpty:
  2121  		apiErr = ErrAdminGroupNotEmpty
  2122  	case errNoSuchJob:
  2123  		apiErr = ErrAdminNoSuchJob
  2124  	case errNoPolicyToAttachOrDetach:
  2125  		apiErr = ErrAdminPolicyChangeAlreadyApplied
  2126  	case errSignatureMismatch:
  2127  		apiErr = ErrSignatureDoesNotMatch
  2128  	case errInvalidRange:
  2129  		apiErr = ErrInvalidRange
  2130  	case errDataTooLarge:
  2131  		apiErr = ErrEntityTooLarge
  2132  	case errDataTooSmall:
  2133  		apiErr = ErrEntityTooSmall
  2134  	case errAuthentication:
  2135  		apiErr = ErrAccessDenied
  2136  	case auth.ErrInvalidAccessKeyLength:
  2137  		apiErr = ErrAdminInvalidAccessKey
  2138  	case auth.ErrInvalidSecretKeyLength:
  2139  		apiErr = ErrAdminInvalidSecretKey
  2140  	case auth.ErrNoAccessKeyWithSecretKey:
  2141  		apiErr = ErrAdminNoAccessKey
  2142  	case auth.ErrNoSecretKeyWithAccessKey:
  2143  		apiErr = ErrAdminNoSecretKey
  2144  	case errInvalidStorageClass:
  2145  		apiErr = ErrInvalidStorageClass
  2146  	case errErasureReadQuorum:
  2147  		apiErr = ErrSlowDownRead
  2148  	case errErasureWriteQuorum:
  2149  		apiErr = ErrSlowDownWrite
  2150  	case errMaxVersionsExceeded:
  2151  		apiErr = ErrMaxVersionsExceeded
  2152  	// SSE errors
  2153  	case errInvalidEncryptionParameters:
  2154  		apiErr = ErrInvalidEncryptionParameters
  2155  	case errInvalidEncryptionParametersSSEC:
  2156  		apiErr = ErrInvalidEncryptionParametersSSEC
  2157  	case crypto.ErrInvalidEncryptionMethod:
  2158  		apiErr = ErrInvalidEncryptionMethod
  2159  	case crypto.ErrInvalidEncryptionKeyID:
  2160  		apiErr = ErrInvalidEncryptionKeyID
  2161  	case crypto.ErrInvalidCustomerAlgorithm:
  2162  		apiErr = ErrInvalidSSECustomerAlgorithm
  2163  	case crypto.ErrMissingCustomerKey:
  2164  		apiErr = ErrMissingSSECustomerKey
  2165  	case crypto.ErrMissingCustomerKeyMD5:
  2166  		apiErr = ErrMissingSSECustomerKeyMD5
  2167  	case crypto.ErrCustomerKeyMD5Mismatch:
  2168  		apiErr = ErrSSECustomerKeyMD5Mismatch
  2169  	case errObjectTampered:
  2170  		apiErr = ErrObjectTampered
  2171  	case errEncryptedObject:
  2172  		apiErr = ErrSSEEncryptedObject
  2173  	case errInvalidSSEParameters:
  2174  		apiErr = ErrInvalidSSECustomerParameters
  2175  	case crypto.ErrInvalidCustomerKey, crypto.ErrSecretKeyMismatch:
  2176  		apiErr = ErrAccessDenied // no access without correct key
  2177  	case crypto.ErrIncompatibleEncryptionMethod:
  2178  		apiErr = ErrIncompatibleEncryptionMethod
  2179  	case errKMSNotConfigured:
  2180  		apiErr = ErrKMSNotConfigured
  2181  	case errKMSKeyNotFound:
  2182  		apiErr = ErrKMSKeyNotFoundException
  2183  	case errKMSDefaultKeyAlreadyConfigured:
  2184  		apiErr = ErrKMSDefaultKeyAlreadyConfigured
  2185  	case context.Canceled:
  2186  		apiErr = ErrClientDisconnected
  2187  	case context.DeadlineExceeded:
  2188  		apiErr = ErrRequestTimedout
  2189  	case objectlock.ErrInvalidRetentionDate:
  2190  		apiErr = ErrInvalidRetentionDate
  2191  	case objectlock.ErrPastObjectLockRetainDate:
  2192  		apiErr = ErrPastObjectLockRetainDate
  2193  	case objectlock.ErrUnknownWORMModeDirective:
  2194  		apiErr = ErrUnknownWORMModeDirective
  2195  	case objectlock.ErrObjectLockInvalidHeaders:
  2196  		apiErr = ErrObjectLockInvalidHeaders
  2197  	case objectlock.ErrMalformedXML:
  2198  		apiErr = ErrMalformedXML
  2199  	case errInvalidMaxParts:
  2200  		apiErr = ErrInvalidMaxParts
  2201  	case ioutil.ErrOverread:
  2202  		apiErr = ErrExcessData
  2203  	}
  2204  
  2205  	// Compression errors
  2206  	if err == errInvalidDecompressedSize {
  2207  		apiErr = ErrInvalidDecompressedSize
  2208  	}
  2209  
  2210  	if apiErr != ErrNone {
  2211  		// If there was a match in the above switch case.
  2212  		return apiErr
  2213  	}
  2214  
  2215  	// etcd specific errors, a key is always a bucket for us return
  2216  	// ErrNoSuchBucket in such a case.
  2217  	if errors.Is(err, dns.ErrNoEntriesFound) {
  2218  		return ErrNoSuchBucket
  2219  	}
  2220  
  2221  	switch err.(type) {
  2222  	case StorageFull:
  2223  		apiErr = ErrStorageFull
  2224  	case hash.BadDigest:
  2225  		apiErr = ErrBadDigest
  2226  	case AllAccessDisabled:
  2227  		apiErr = ErrAllAccessDisabled
  2228  	case IncompleteBody:
  2229  		apiErr = ErrIncompleteBody
  2230  	case ObjectExistsAsDirectory:
  2231  		apiErr = ErrObjectExistsAsDirectory
  2232  	case PrefixAccessDenied:
  2233  		apiErr = ErrAccessDenied
  2234  	case BucketNameInvalid:
  2235  		apiErr = ErrInvalidBucketName
  2236  	case BucketNotFound:
  2237  		apiErr = ErrNoSuchBucket
  2238  	case BucketAlreadyOwnedByYou:
  2239  		apiErr = ErrBucketAlreadyOwnedByYou
  2240  	case BucketNotEmpty:
  2241  		apiErr = ErrBucketNotEmpty
  2242  	case BucketAlreadyExists:
  2243  		apiErr = ErrBucketAlreadyExists
  2244  	case BucketExists:
  2245  		apiErr = ErrBucketAlreadyOwnedByYou
  2246  	case ObjectNotFound:
  2247  		apiErr = ErrNoSuchKey
  2248  	case MethodNotAllowed:
  2249  		apiErr = ErrMethodNotAllowed
  2250  	case ObjectLocked:
  2251  		apiErr = ErrObjectLocked
  2252  	case InvalidVersionID:
  2253  		apiErr = ErrInvalidVersionID
  2254  	case VersionNotFound:
  2255  		apiErr = ErrNoSuchVersion
  2256  	case ObjectAlreadyExists:
  2257  		apiErr = ErrMethodNotAllowed
  2258  	case ObjectNameInvalid:
  2259  		apiErr = ErrInvalidObjectName
  2260  	case ObjectNamePrefixAsSlash:
  2261  		apiErr = ErrInvalidObjectNamePrefixSlash
  2262  	case InvalidUploadID:
  2263  		apiErr = ErrNoSuchUpload
  2264  	case InvalidPart:
  2265  		apiErr = ErrInvalidPart
  2266  	case InsufficientWriteQuorum:
  2267  		apiErr = ErrSlowDownWrite
  2268  	case InsufficientReadQuorum:
  2269  		apiErr = ErrSlowDownRead
  2270  	case InvalidUploadIDKeyCombination:
  2271  		apiErr = ErrNotImplemented
  2272  	case MalformedUploadID:
  2273  		apiErr = ErrNoSuchUpload
  2274  	case PartTooSmall:
  2275  		apiErr = ErrEntityTooSmall
  2276  	case SignatureDoesNotMatch:
  2277  		apiErr = ErrSignatureDoesNotMatch
  2278  	case hash.SHA256Mismatch:
  2279  		apiErr = ErrContentSHA256Mismatch
  2280  	case hash.ChecksumMismatch:
  2281  		apiErr = ErrContentChecksumMismatch
  2282  	case hash.SizeTooSmall:
  2283  		apiErr = ErrEntityTooSmall
  2284  	case hash.SizeTooLarge:
  2285  		apiErr = ErrEntityTooLarge
  2286  	case NotImplemented:
  2287  		apiErr = ErrNotImplemented
  2288  	case PartTooBig:
  2289  		apiErr = ErrEntityTooLarge
  2290  	case UnsupportedMetadata:
  2291  		apiErr = ErrUnsupportedMetadata
  2292  	case BucketPolicyNotFound:
  2293  		apiErr = ErrNoSuchBucketPolicy
  2294  	case BucketLifecycleNotFound:
  2295  		apiErr = ErrNoSuchLifecycleConfiguration
  2296  	case BucketSSEConfigNotFound:
  2297  		apiErr = ErrNoSuchBucketSSEConfig
  2298  	case BucketTaggingNotFound:
  2299  		apiErr = ErrBucketTaggingNotFound
  2300  	case BucketObjectLockConfigNotFound:
  2301  		apiErr = ErrObjectLockConfigurationNotFound
  2302  	case BucketQuotaConfigNotFound:
  2303  		apiErr = ErrAdminNoSuchQuotaConfiguration
  2304  	case BucketReplicationConfigNotFound:
  2305  		apiErr = ErrReplicationConfigurationNotFoundError
  2306  	case BucketRemoteDestinationNotFound:
  2307  		apiErr = ErrRemoteDestinationNotFoundError
  2308  	case BucketRemoteTargetNotFound:
  2309  		apiErr = ErrRemoteTargetNotFoundError
  2310  	case RemoteTargetConnectionErr:
  2311  		apiErr = ErrReplicationRemoteConnectionError
  2312  	case BucketRemoteAlreadyExists:
  2313  		apiErr = ErrBucketRemoteAlreadyExists
  2314  	case BucketRemoteLabelInUse:
  2315  		apiErr = ErrBucketRemoteLabelInUse
  2316  	case BucketRemoteArnTypeInvalid:
  2317  		apiErr = ErrBucketRemoteArnTypeInvalid
  2318  	case BucketRemoteArnInvalid:
  2319  		apiErr = ErrBucketRemoteArnInvalid
  2320  	case BucketRemoteRemoveDisallowed:
  2321  		apiErr = ErrBucketRemoteRemoveDisallowed
  2322  	case BucketRemoteTargetNotVersioned:
  2323  		apiErr = ErrRemoteTargetNotVersionedError
  2324  	case BucketReplicationSourceNotVersioned:
  2325  		apiErr = ErrReplicationSourceNotVersionedError
  2326  	case TransitionStorageClassNotFound:
  2327  		apiErr = ErrTransitionStorageClassNotFoundError
  2328  	case InvalidObjectState:
  2329  		apiErr = ErrInvalidObjectState
  2330  	case PreConditionFailed:
  2331  		apiErr = ErrPreconditionFailed
  2332  	case BucketQuotaExceeded:
  2333  		apiErr = ErrAdminBucketQuotaExceeded
  2334  	case *event.ErrInvalidEventName:
  2335  		apiErr = ErrEventNotification
  2336  	case *event.ErrInvalidARN:
  2337  		apiErr = ErrARNNotification
  2338  	case *event.ErrARNNotFound:
  2339  		apiErr = ErrARNNotification
  2340  	case *levent.ErrInvalidARN:
  2341  		apiErr = ErrLambdaARNInvalid
  2342  	case *levent.ErrARNNotFound:
  2343  		apiErr = ErrLambdaARNNotFound
  2344  	case *event.ErrUnknownRegion:
  2345  		apiErr = ErrRegionNotification
  2346  	case *event.ErrInvalidFilterName:
  2347  		apiErr = ErrFilterNameInvalid
  2348  	case *event.ErrFilterNamePrefix:
  2349  		apiErr = ErrFilterNamePrefix
  2350  	case *event.ErrFilterNameSuffix:
  2351  		apiErr = ErrFilterNameSuffix
  2352  	case *event.ErrInvalidFilterValue:
  2353  		apiErr = ErrFilterValueInvalid
  2354  	case *event.ErrDuplicateEventName:
  2355  		apiErr = ErrOverlappingConfigs
  2356  	case *event.ErrDuplicateQueueConfiguration:
  2357  		apiErr = ErrOverlappingFilterNotification
  2358  	case *event.ErrUnsupportedConfiguration:
  2359  		apiErr = ErrUnsupportedNotification
  2360  	case OperationTimedOut:
  2361  		apiErr = ErrRequestTimedout
  2362  	case BackendDown:
  2363  		apiErr = ErrBackendDown
  2364  	case ObjectNameTooLong:
  2365  		apiErr = ErrKeyTooLongError
  2366  	case dns.ErrInvalidBucketName:
  2367  		apiErr = ErrInvalidBucketName
  2368  	case dns.ErrBucketConflict:
  2369  		apiErr = ErrBucketAlreadyExists
  2370  	default:
  2371  		if strings.Contains(err.Error(), "request declared a Content-Length") {
  2372  			apiErr = ErrIncompleteBody
  2373  		} else {
  2374  			apiErr = ErrInternalError
  2375  		}
  2376  	}
  2377  
  2378  	return apiErr
  2379  }
  2380  
  2381  var noError = APIError{}
  2382  
  2383  // toAPIError - Converts embedded errors. Convenience
  2384  // function written to handle all cases where we have known types of
  2385  // errors returned by underlying layers.
  2386  func toAPIError(ctx context.Context, err error) APIError {
  2387  	if err == nil {
  2388  		return noError
  2389  	}
  2390  
  2391  	apiErr := errorCodes.ToAPIErr(toAPIErrorCode(ctx, err))
  2392  	switch apiErr.Code {
  2393  	case "NotImplemented":
  2394  		desc := fmt.Sprintf("%s (%v)", apiErr.Description, err)
  2395  		apiErr = APIError{
  2396  			Code:           apiErr.Code,
  2397  			Description:    desc,
  2398  			HTTPStatusCode: apiErr.HTTPStatusCode,
  2399  		}
  2400  	case "XMinioBackendDown":
  2401  		apiErr.Description = fmt.Sprintf("%s (%v)", apiErr.Description, err)
  2402  	case "InternalError":
  2403  		// If we see an internal error try to interpret
  2404  		// any underlying errors if possible depending on
  2405  		// their internal error types.
  2406  		switch e := err.(type) {
  2407  		case kms.Error:
  2408  			apiErr = APIError{
  2409  				Description:    e.Err.Error(),
  2410  				Code:           e.APICode,
  2411  				HTTPStatusCode: e.HTTPStatusCode,
  2412  			}
  2413  		case batchReplicationJobError:
  2414  			apiErr = APIError(e)
  2415  		case InvalidArgument:
  2416  			apiErr = APIError{
  2417  				Code:           "InvalidArgument",
  2418  				Description:    e.Error(),
  2419  				HTTPStatusCode: errorCodes[ErrInvalidRequest].HTTPStatusCode,
  2420  			}
  2421  		case *xml.SyntaxError:
  2422  			apiErr = APIError{
  2423  				Code:           "MalformedXML",
  2424  				Description:    fmt.Sprintf("%s (%s)", errorCodes[ErrMalformedXML].Description, e),
  2425  				HTTPStatusCode: errorCodes[ErrMalformedXML].HTTPStatusCode,
  2426  			}
  2427  		case url.EscapeError:
  2428  			apiErr = APIError{
  2429  				Code:           "XMinioInvalidObjectName",
  2430  				Description:    fmt.Sprintf("%s (%s)", errorCodes[ErrInvalidObjectName].Description, e),
  2431  				HTTPStatusCode: http.StatusBadRequest,
  2432  			}
  2433  		case versioning.Error:
  2434  			apiErr = APIError{
  2435  				Code:           "IllegalVersioningConfigurationException",
  2436  				Description:    fmt.Sprintf("Versioning configuration specified in the request is invalid. (%s)", e),
  2437  				HTTPStatusCode: http.StatusBadRequest,
  2438  			}
  2439  		case lifecycle.Error:
  2440  			apiErr = APIError{
  2441  				Code:           "InvalidArgument",
  2442  				Description:    e.Error(),
  2443  				HTTPStatusCode: http.StatusBadRequest,
  2444  			}
  2445  		case replication.Error:
  2446  			apiErr = APIError{
  2447  				Code:           "MalformedXML",
  2448  				Description:    e.Error(),
  2449  				HTTPStatusCode: http.StatusBadRequest,
  2450  			}
  2451  		case tags.Error:
  2452  			apiErr = APIError{
  2453  				Code:           e.Code(),
  2454  				Description:    e.Error(),
  2455  				HTTPStatusCode: http.StatusBadRequest,
  2456  			}
  2457  		case policy.Error:
  2458  			apiErr = APIError{
  2459  				Code:           "MalformedPolicy",
  2460  				Description:    e.Error(),
  2461  				HTTPStatusCode: http.StatusBadRequest,
  2462  			}
  2463  		case crypto.Error:
  2464  			apiErr = APIError{
  2465  				Code:           "XMinioEncryptionError",
  2466  				Description:    e.Error(),
  2467  				HTTPStatusCode: http.StatusBadRequest,
  2468  			}
  2469  		case minio.ErrorResponse:
  2470  			apiErr = APIError{
  2471  				Code:           e.Code,
  2472  				Description:    e.Message,
  2473  				HTTPStatusCode: e.StatusCode,
  2474  			}
  2475  			if strings.Contains(e.Message, "KMS is not configured") {
  2476  				apiErr = APIError{
  2477  					Code:           "NotImplemented",
  2478  					Description:    e.Message,
  2479  					HTTPStatusCode: http.StatusNotImplemented,
  2480  				}
  2481  			}
  2482  		case *googleapi.Error:
  2483  			apiErr = APIError{
  2484  				Code:           "XGCSInternalError",
  2485  				Description:    e.Message,
  2486  				HTTPStatusCode: e.Code,
  2487  			}
  2488  			// GCS may send multiple errors, just pick the first one
  2489  			// since S3 only sends one Error XML response.
  2490  			if len(e.Errors) >= 1 {
  2491  				apiErr.Code = e.Errors[0].Reason
  2492  			}
  2493  		case azblob.StorageError:
  2494  			apiErr = APIError{
  2495  				Code:           string(e.ServiceCode()),
  2496  				Description:    e.Error(),
  2497  				HTTPStatusCode: e.Response().StatusCode,
  2498  			}
  2499  			// Add more other SDK related errors here if any in future.
  2500  		default:
  2501  			//nolint:gocritic
  2502  			if errors.Is(err, errMalformedEncoding) || errors.Is(err, errChunkTooBig) || errors.Is(err, strconv.ErrRange) {
  2503  				apiErr = APIError{
  2504  					Code:           "BadRequest",
  2505  					Description:    err.Error(),
  2506  					HTTPStatusCode: http.StatusBadRequest,
  2507  				}
  2508  			} else {
  2509  				apiErr = APIError{
  2510  					Code:           apiErr.Code,
  2511  					Description:    fmt.Sprintf("%s: cause(%v)", apiErr.Description, err),
  2512  					HTTPStatusCode: apiErr.HTTPStatusCode,
  2513  				}
  2514  			}
  2515  		}
  2516  	}
  2517  
  2518  	if apiErr.Code == "InternalError" {
  2519  		// Make sure to log the errors which we cannot translate
  2520  		// to a meaningful S3 API errors. This is added to aid in
  2521  		// debugging unexpected/unhandled errors.
  2522  		logger.LogIf(ctx, err)
  2523  	}
  2524  
  2525  	return apiErr
  2526  }
  2527  
  2528  // getAPIError provides API Error for input API error code.
  2529  func getAPIError(code APIErrorCode) APIError {
  2530  	if apiErr, ok := errorCodes[code]; ok {
  2531  		return apiErr
  2532  	}
  2533  	return errorCodes.ToAPIErr(ErrInternalError)
  2534  }
  2535  
  2536  // getErrorResponse gets in standard error and resource value and
  2537  // provides a encodable populated response values
  2538  func getAPIErrorResponse(ctx context.Context, err APIError, resource, requestID, hostID string) APIErrorResponse {
  2539  	reqInfo := logger.GetReqInfo(ctx)
  2540  	return APIErrorResponse{
  2541  		Code:       err.Code,
  2542  		Message:    err.Description,
  2543  		BucketName: reqInfo.BucketName,
  2544  		Key:        reqInfo.ObjectName,
  2545  		Resource:   resource,
  2546  		Region:     globalSite.Region,
  2547  		RequestID:  requestID,
  2548  		HostID:     hostID,
  2549  	}
  2550  }