s3api_errors.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. package s3err
  2. import (
  3. "encoding/xml"
  4. "fmt"
  5. "net/http"
  6. "github.com/seaweedfs/seaweedfs/weed/util/constants"
  7. )
  8. // APIError structure
  9. type APIError struct {
  10. Code string
  11. Description string
  12. HTTPStatusCode int
  13. }
  14. // RESTErrorResponse - error response format
  15. type RESTErrorResponse struct {
  16. XMLName xml.Name `xml:"Error" json:"-"`
  17. Code string `xml:"Code" json:"Code"`
  18. Message string `xml:"Message" json:"Message"`
  19. Resource string `xml:"Resource" json:"Resource"`
  20. RequestID string `xml:"RequestId" json:"RequestId"`
  21. Key string `xml:"Key,omitempty" json:"Key,omitempty"`
  22. BucketName string `xml:"BucketName,omitempty" json:"BucketName,omitempty"`
  23. // Underlying HTTP status code for the returned error
  24. StatusCode int `xml:"-" json:"-"`
  25. }
  26. // Error - Returns S3 error string.
  27. func (e RESTErrorResponse) Error() string {
  28. if e.Message == "" {
  29. msg, ok := s3ErrorResponseMap[e.Code]
  30. if !ok {
  31. msg = fmt.Sprintf("Error response code %s.", e.Code)
  32. }
  33. return msg
  34. }
  35. return e.Message
  36. }
  37. // ErrorCode type of error status.
  38. type ErrorCode int
  39. // Error codes, see full list at http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
  40. const (
  41. ErrNone ErrorCode = iota
  42. ErrAccessDenied
  43. ErrMethodNotAllowed
  44. ErrBucketNotEmpty
  45. ErrBucketAlreadyExists
  46. ErrBucketAlreadyOwnedByYou
  47. ErrNoSuchBucket
  48. ErrNoSuchBucketPolicy
  49. ErrNoSuchCORSConfiguration
  50. ErrNoSuchLifecycleConfiguration
  51. ErrNoSuchKey
  52. ErrNoSuchUpload
  53. ErrInvalidBucketName
  54. ErrInvalidBucketState
  55. ErrInvalidDigest
  56. ErrBadDigest
  57. ErrInvalidMaxKeys
  58. ErrInvalidMaxUploads
  59. ErrInvalidMaxParts
  60. ErrInvalidMaxDeleteObjects
  61. ErrInvalidPartNumberMarker
  62. ErrInvalidPart
  63. ErrInvalidRange
  64. ErrInternalError
  65. ErrInvalidCopyDest
  66. ErrInvalidCopySource
  67. ErrInvalidTag
  68. ErrAuthHeaderEmpty
  69. ErrSignatureVersionNotSupported
  70. ErrMalformedPOSTRequest
  71. ErrPOSTFileRequired
  72. ErrPostPolicyConditionInvalidFormat
  73. ErrEntityTooSmall
  74. ErrEntityTooLarge
  75. ErrMissingFields
  76. ErrMissingCredTag
  77. ErrCredMalformed
  78. ErrMalformedXML
  79. ErrMalformedDate
  80. ErrMalformedPresignedDate
  81. ErrMalformedCredentialDate
  82. ErrMalformedPolicy
  83. ErrInvalidPolicyDocument
  84. ErrMissingSignHeadersTag
  85. ErrMissingSignTag
  86. ErrUnsignedHeaders
  87. ErrInvalidQueryParams
  88. ErrInvalidQuerySignatureAlgo
  89. ErrExpiredPresignRequest
  90. ErrMalformedExpires
  91. ErrNegativeExpires
  92. ErrMaximumExpires
  93. ErrSignatureDoesNotMatch
  94. ErrContentSHA256Mismatch
  95. ErrInvalidAccessKeyID
  96. ErrRequestNotReadyYet
  97. ErrMissingDateHeader
  98. ErrInvalidRequest
  99. ErrAuthNotSetup
  100. ErrNotImplemented
  101. ErrPreconditionFailed
  102. ErrNotModified
  103. ErrExistingObjectIsDirectory
  104. ErrExistingObjectIsFile
  105. ErrTooManyRequest
  106. ErrRequestBytesExceed
  107. OwnershipControlsNotFoundError
  108. ErrNoSuchTagSet
  109. ErrNoSuchObjectLockConfiguration
  110. ErrNoSuchObjectLegalHold
  111. ErrInvalidRetentionPeriod
  112. ErrObjectLockConfigurationNotFoundError
  113. ErrInvalidUnorderedWithDelimiter
  114. // SSE-C related errors
  115. ErrInvalidEncryptionAlgorithm
  116. ErrInvalidEncryptionKey
  117. ErrSSECustomerKeyMD5Mismatch
  118. ErrSSECustomerKeyMissing
  119. ErrSSECustomerKeyNotNeeded
  120. // SSE-KMS related errors
  121. ErrKMSKeyNotFound
  122. ErrKMSAccessDenied
  123. ErrKMSDisabled
  124. ErrKMSInvalidCiphertext
  125. // Bucket encryption errors
  126. ErrNoSuchBucketEncryptionConfiguration
  127. )
  128. // Error message constants for checksum validation
  129. const (
  130. ErrMsgPayloadChecksumMismatch = "payload checksum does not match"
  131. ErrMsgChunkSignatureMismatch = "chunk signature does not match"
  132. ErrMsgChecksumAlgorithmMismatch = "checksum algorithm mismatch"
  133. )
  134. // error code to APIError structure, these fields carry respective
  135. // descriptions for all the error responses.
  136. var errorCodeResponse = map[ErrorCode]APIError{
  137. ErrAccessDenied: {
  138. Code: "AccessDenied",
  139. Description: "Access Denied.",
  140. HTTPStatusCode: http.StatusForbidden,
  141. },
  142. ErrMethodNotAllowed: {
  143. Code: "MethodNotAllowed",
  144. Description: "The specified method is not allowed against this resource.",
  145. HTTPStatusCode: http.StatusMethodNotAllowed,
  146. },
  147. ErrBucketNotEmpty: {
  148. Code: "BucketNotEmpty",
  149. Description: "The bucket you tried to delete is not empty",
  150. HTTPStatusCode: http.StatusConflict,
  151. },
  152. ErrBucketAlreadyExists: {
  153. Code: "BucketAlreadyExists",
  154. Description: "The requested bucket name is not available. The bucket name can not be an existing collection, and the bucket namespace is shared by all users of the system. Please select a different name and try again.",
  155. HTTPStatusCode: http.StatusConflict,
  156. },
  157. ErrBucketAlreadyOwnedByYou: {
  158. Code: "BucketAlreadyOwnedByYou",
  159. Description: "Your previous request to create the named bucket succeeded and you already own it.",
  160. HTTPStatusCode: http.StatusConflict,
  161. },
  162. ErrInvalidBucketName: {
  163. Code: "InvalidBucketName",
  164. Description: "The specified bucket is not valid.",
  165. HTTPStatusCode: http.StatusBadRequest,
  166. },
  167. ErrInvalidBucketState: {
  168. Code: "InvalidBucketState",
  169. Description: "The bucket is not in a valid state for the requested operation",
  170. HTTPStatusCode: http.StatusConflict,
  171. },
  172. ErrInvalidDigest: {
  173. Code: "InvalidDigest",
  174. Description: "The Content-Md5 you specified is not valid.",
  175. HTTPStatusCode: http.StatusBadRequest,
  176. },
  177. ErrBadDigest: {
  178. Code: "BadDigest",
  179. Description: constants.ErrMsgBadDigest,
  180. HTTPStatusCode: http.StatusBadRequest,
  181. },
  182. ErrInvalidMaxUploads: {
  183. Code: "InvalidArgument",
  184. Description: "Argument max-uploads must be an integer between 0 and 2147483647",
  185. HTTPStatusCode: http.StatusBadRequest,
  186. },
  187. ErrInvalidMaxKeys: {
  188. Code: "InvalidArgument",
  189. Description: "Argument maxKeys must be an integer between 0 and 2147483647",
  190. HTTPStatusCode: http.StatusBadRequest,
  191. },
  192. ErrInvalidMaxParts: {
  193. Code: "InvalidArgument",
  194. Description: "Argument max-parts must be an integer between 0 and 2147483647",
  195. HTTPStatusCode: http.StatusBadRequest,
  196. },
  197. ErrInvalidMaxDeleteObjects: {
  198. Code: "InvalidArgument",
  199. Description: "Argument objects can contain a list of up to 1000 keys",
  200. HTTPStatusCode: http.StatusBadRequest,
  201. },
  202. ErrInvalidPartNumberMarker: {
  203. Code: "InvalidArgument",
  204. Description: "Argument partNumberMarker must be an integer.",
  205. HTTPStatusCode: http.StatusBadRequest,
  206. },
  207. ErrNoSuchBucket: {
  208. Code: "NoSuchBucket",
  209. Description: "The specified bucket does not exist",
  210. HTTPStatusCode: http.StatusNotFound,
  211. },
  212. ErrNoSuchBucketPolicy: {
  213. Code: "NoSuchBucketPolicy",
  214. Description: "The bucket policy does not exist",
  215. HTTPStatusCode: http.StatusNotFound,
  216. },
  217. ErrNoSuchTagSet: {
  218. Code: "NoSuchTagSet",
  219. Description: "The TagSet does not exist",
  220. HTTPStatusCode: http.StatusNotFound,
  221. },
  222. ErrNoSuchObjectLockConfiguration: {
  223. Code: "NoSuchObjectLockConfiguration",
  224. Description: "The specified object does not have an ObjectLock configuration",
  225. HTTPStatusCode: http.StatusNotFound,
  226. },
  227. ErrNoSuchObjectLegalHold: {
  228. Code: "NoSuchObjectLegalHold",
  229. Description: "The specified object does not have a legal hold configuration",
  230. HTTPStatusCode: http.StatusNotFound,
  231. },
  232. ErrInvalidRetentionPeriod: {
  233. Code: "InvalidRetentionPeriod",
  234. Description: "The retention period specified is invalid",
  235. HTTPStatusCode: http.StatusBadRequest,
  236. },
  237. ErrNoSuchCORSConfiguration: {
  238. Code: "NoSuchCORSConfiguration",
  239. Description: "The CORS configuration does not exist",
  240. HTTPStatusCode: http.StatusNotFound,
  241. },
  242. ErrNoSuchLifecycleConfiguration: {
  243. Code: "NoSuchLifecycleConfiguration",
  244. Description: "The lifecycle configuration does not exist",
  245. HTTPStatusCode: http.StatusNotFound,
  246. },
  247. ErrNoSuchKey: {
  248. Code: "NoSuchKey",
  249. Description: "The specified key does not exist.",
  250. HTTPStatusCode: http.StatusNotFound,
  251. },
  252. ErrNoSuchUpload: {
  253. Code: "NoSuchUpload",
  254. Description: "The specified multipart upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",
  255. HTTPStatusCode: http.StatusNotFound,
  256. },
  257. ErrInternalError: {
  258. Code: "InternalError",
  259. Description: "We encountered an internal error, please try again.",
  260. HTTPStatusCode: http.StatusInternalServerError,
  261. },
  262. ErrInvalidPart: {
  263. Code: "InvalidPart",
  264. 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.",
  265. HTTPStatusCode: http.StatusBadRequest,
  266. },
  267. ErrInvalidCopyDest: {
  268. Code: "InvalidRequest",
  269. 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.",
  270. HTTPStatusCode: http.StatusBadRequest,
  271. },
  272. ErrInvalidCopySource: {
  273. Code: "InvalidArgument",
  274. Description: "Copy Source must mention the source bucket and key: sourcebucket/sourcekey.",
  275. HTTPStatusCode: http.StatusBadRequest,
  276. },
  277. ErrInvalidTag: {
  278. Code: "InvalidTag",
  279. Description: "The Tag value you have provided is invalid",
  280. HTTPStatusCode: http.StatusBadRequest,
  281. },
  282. ErrMalformedXML: {
  283. Code: "MalformedXML",
  284. Description: "The XML you provided was not well-formed or did not validate against our published schema.",
  285. HTTPStatusCode: http.StatusBadRequest,
  286. },
  287. ErrMalformedPolicy: {
  288. Code: "MalformedPolicy",
  289. Description: "Policy has invalid resource.",
  290. HTTPStatusCode: http.StatusBadRequest,
  291. },
  292. ErrInvalidPolicyDocument: {
  293. Code: "InvalidPolicyDocument",
  294. Description: "The content of the policy document is invalid.",
  295. HTTPStatusCode: http.StatusBadRequest,
  296. },
  297. ErrAuthHeaderEmpty: {
  298. Code: "InvalidArgument",
  299. Description: "Authorization header is invalid -- one and only one ' ' (space) required.",
  300. HTTPStatusCode: http.StatusBadRequest,
  301. },
  302. ErrSignatureVersionNotSupported: {
  303. Code: "InvalidRequest",
  304. Description: "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.",
  305. HTTPStatusCode: http.StatusBadRequest,
  306. },
  307. ErrMalformedPOSTRequest: {
  308. Code: "MalformedPOSTRequest",
  309. Description: "The body of your POST request is not well-formed multipart/form-data.",
  310. HTTPStatusCode: http.StatusBadRequest,
  311. },
  312. ErrPOSTFileRequired: {
  313. Code: "InvalidArgument",
  314. Description: "POST requires exactly one file upload per request.",
  315. HTTPStatusCode: http.StatusBadRequest,
  316. },
  317. ErrPostPolicyConditionInvalidFormat: {
  318. Code: "PostPolicyInvalidKeyName",
  319. Description: "Invalid according to Policy: Policy Condition failed",
  320. HTTPStatusCode: http.StatusForbidden,
  321. },
  322. ErrEntityTooSmall: {
  323. Code: "EntityTooSmall",
  324. Description: "Your proposed upload is smaller than the minimum allowed object size.",
  325. HTTPStatusCode: http.StatusBadRequest,
  326. },
  327. ErrEntityTooLarge: {
  328. Code: "EntityTooLarge",
  329. Description: "Your proposed upload exceeds the maximum allowed object size.",
  330. HTTPStatusCode: http.StatusBadRequest,
  331. },
  332. ErrMissingFields: {
  333. Code: "MissingFields",
  334. Description: "Missing fields in request.",
  335. HTTPStatusCode: http.StatusBadRequest,
  336. },
  337. ErrMissingCredTag: {
  338. Code: "InvalidRequest",
  339. Description: "Missing Credential field for this request.",
  340. HTTPStatusCode: http.StatusBadRequest,
  341. },
  342. ErrCredMalformed: {
  343. Code: "AuthorizationQueryParametersError",
  344. Description: "Error parsing the X-Amz-Credential parameter; the Credential is mal-formed; expecting \"<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request\".",
  345. HTTPStatusCode: http.StatusBadRequest,
  346. },
  347. ErrMalformedDate: {
  348. Code: "MalformedDate",
  349. Description: "Invalid date format header, expected to be in ISO8601, RFC1123 or RFC1123Z time format.",
  350. HTTPStatusCode: http.StatusBadRequest,
  351. },
  352. ErrMalformedPresignedDate: {
  353. Code: "AuthorizationQueryParametersError",
  354. Description: "X-Amz-Date must be in the ISO8601 Long Format \"yyyyMMdd'T'HHmmss'Z'\"",
  355. HTTPStatusCode: http.StatusBadRequest,
  356. },
  357. ErrMissingSignHeadersTag: {
  358. Code: "InvalidArgument",
  359. Description: "Signature header missing SignedHeaders field.",
  360. HTTPStatusCode: http.StatusBadRequest,
  361. },
  362. ErrMissingSignTag: {
  363. Code: "AccessDenied",
  364. Description: "Signature header missing Signature field.",
  365. HTTPStatusCode: http.StatusBadRequest,
  366. },
  367. ErrUnsignedHeaders: {
  368. Code: "AccessDenied",
  369. Description: "There were headers present in the request which were not signed",
  370. HTTPStatusCode: http.StatusBadRequest,
  371. },
  372. ErrInvalidQueryParams: {
  373. Code: "AuthorizationQueryParametersError",
  374. 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.",
  375. HTTPStatusCode: http.StatusBadRequest,
  376. },
  377. ErrInvalidQuerySignatureAlgo: {
  378. Code: "AuthorizationQueryParametersError",
  379. Description: "X-Amz-Algorithm only supports \"AWS4-HMAC-SHA256\".",
  380. HTTPStatusCode: http.StatusBadRequest,
  381. },
  382. ErrExpiredPresignRequest: {
  383. Code: "AccessDenied",
  384. Description: "Request has expired",
  385. HTTPStatusCode: http.StatusForbidden,
  386. },
  387. ErrMalformedExpires: {
  388. Code: "AuthorizationQueryParametersError",
  389. Description: "X-Amz-Expires should be a number",
  390. HTTPStatusCode: http.StatusBadRequest,
  391. },
  392. ErrNegativeExpires: {
  393. Code: "AuthorizationQueryParametersError",
  394. Description: "X-Amz-Expires must be non-negative",
  395. HTTPStatusCode: http.StatusBadRequest,
  396. },
  397. ErrMaximumExpires: {
  398. Code: "AuthorizationQueryParametersError",
  399. 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",
  400. HTTPStatusCode: http.StatusBadRequest,
  401. },
  402. ErrInvalidAccessKeyID: {
  403. Code: "InvalidAccessKeyId",
  404. Description: "The access key ID you provided does not exist in our records.",
  405. HTTPStatusCode: http.StatusForbidden,
  406. },
  407. ErrRequestNotReadyYet: {
  408. Code: "AccessDenied",
  409. Description: "Request is not valid yet",
  410. HTTPStatusCode: http.StatusForbidden,
  411. },
  412. ErrSignatureDoesNotMatch: {
  413. Code: "SignatureDoesNotMatch",
  414. Description: "The request signature we calculated does not match the signature you provided. Check your key and signing method.",
  415. HTTPStatusCode: http.StatusForbidden,
  416. },
  417. ErrContentSHA256Mismatch: {
  418. Code: "XAmzContentSHA256Mismatch",
  419. Description: "The provided 'x-amz-content-sha256' header does not match what was computed.",
  420. HTTPStatusCode: http.StatusBadRequest,
  421. },
  422. ErrMissingDateHeader: {
  423. Code: "AccessDenied",
  424. Description: "AWS authentication requires a valid Date or x-amz-date header",
  425. HTTPStatusCode: http.StatusBadRequest,
  426. },
  427. ErrInvalidRequest: {
  428. Code: "InvalidRequest",
  429. Description: "Invalid Request",
  430. HTTPStatusCode: http.StatusBadRequest,
  431. },
  432. ErrInvalidRange: {
  433. Code: "InvalidRange",
  434. Description: "The requested range is not satisfiable",
  435. HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
  436. },
  437. ErrAuthNotSetup: {
  438. Code: "InvalidRequest",
  439. Description: "Signed request requires setting up SeaweedFS S3 authentication",
  440. HTTPStatusCode: http.StatusBadRequest,
  441. },
  442. ErrNotImplemented: {
  443. Code: "NotImplemented",
  444. Description: "A header you provided implies functionality that is not implemented",
  445. HTTPStatusCode: http.StatusNotImplemented,
  446. },
  447. ErrPreconditionFailed: {
  448. Code: "PreconditionFailed",
  449. Description: "At least one of the pre-conditions you specified did not hold",
  450. HTTPStatusCode: http.StatusPreconditionFailed,
  451. },
  452. ErrNotModified: {
  453. Code: "NotModified",
  454. Description: "The object was not modified since the specified time",
  455. HTTPStatusCode: http.StatusNotModified,
  456. },
  457. ErrExistingObjectIsDirectory: {
  458. Code: "ExistingObjectIsDirectory",
  459. Description: "Existing Object is a directory.",
  460. HTTPStatusCode: http.StatusConflict,
  461. },
  462. ErrExistingObjectIsFile: {
  463. Code: "ExistingObjectIsFile",
  464. Description: "Existing Object is a file.",
  465. HTTPStatusCode: http.StatusConflict,
  466. },
  467. ErrTooManyRequest: {
  468. Code: "ErrTooManyRequest",
  469. Description: "Too many simultaneous request count",
  470. HTTPStatusCode: http.StatusTooManyRequests,
  471. },
  472. ErrRequestBytesExceed: {
  473. Code: "ErrRequestBytesExceed",
  474. Description: "Simultaneous request bytes exceed limitations",
  475. HTTPStatusCode: http.StatusTooManyRequests,
  476. },
  477. OwnershipControlsNotFoundError: {
  478. Code: "OwnershipControlsNotFoundError",
  479. Description: "The bucket ownership controls were not found",
  480. HTTPStatusCode: http.StatusNotFound,
  481. },
  482. ErrObjectLockConfigurationNotFoundError: {
  483. Code: "ObjectLockConfigurationNotFoundError",
  484. Description: "Object Lock configuration does not exist for this bucket",
  485. HTTPStatusCode: http.StatusNotFound,
  486. },
  487. ErrInvalidUnorderedWithDelimiter: {
  488. Code: "InvalidArgument",
  489. Description: "Unordered listing cannot be used with delimiter",
  490. HTTPStatusCode: http.StatusBadRequest,
  491. },
  492. // SSE-C related error mappings
  493. ErrInvalidEncryptionAlgorithm: {
  494. Code: "InvalidEncryptionAlgorithmError",
  495. Description: "The encryption algorithm specified is not valid.",
  496. HTTPStatusCode: http.StatusBadRequest,
  497. },
  498. ErrInvalidEncryptionKey: {
  499. Code: "InvalidArgument",
  500. Description: "Invalid encryption key. Encryption key must be 256-bit AES256.",
  501. HTTPStatusCode: http.StatusBadRequest,
  502. },
  503. ErrSSECustomerKeyMD5Mismatch: {
  504. Code: "InvalidArgument",
  505. Description: "The provided customer encryption key MD5 does not match the key.",
  506. HTTPStatusCode: http.StatusBadRequest,
  507. },
  508. ErrSSECustomerKeyMissing: {
  509. Code: "InvalidArgument",
  510. Description: "Requests specifying Server Side Encryption with Customer provided keys must provide the customer key.",
  511. HTTPStatusCode: http.StatusBadRequest,
  512. },
  513. ErrSSECustomerKeyNotNeeded: {
  514. Code: "InvalidArgument",
  515. Description: "The object was not encrypted with customer provided keys.",
  516. HTTPStatusCode: http.StatusBadRequest,
  517. },
  518. // SSE-KMS error responses
  519. ErrKMSKeyNotFound: {
  520. Code: "KMSKeyNotFoundException",
  521. Description: "The specified KMS key does not exist.",
  522. HTTPStatusCode: http.StatusBadRequest,
  523. },
  524. ErrKMSAccessDenied: {
  525. Code: "KMSAccessDeniedException",
  526. Description: "Access denied to the specified KMS key.",
  527. HTTPStatusCode: http.StatusForbidden,
  528. },
  529. ErrKMSDisabled: {
  530. Code: "KMSKeyDisabledException",
  531. Description: "The specified KMS key is disabled.",
  532. HTTPStatusCode: http.StatusBadRequest,
  533. },
  534. ErrKMSInvalidCiphertext: {
  535. Code: "InvalidCiphertext",
  536. Description: "The provided ciphertext is invalid or corrupted.",
  537. HTTPStatusCode: http.StatusBadRequest,
  538. },
  539. // Bucket encryption error responses
  540. ErrNoSuchBucketEncryptionConfiguration: {
  541. Code: "ServerSideEncryptionConfigurationNotFoundError",
  542. Description: "The server side encryption configuration was not found.",
  543. HTTPStatusCode: http.StatusNotFound,
  544. },
  545. }
  546. // GetAPIError provides API Error for input API error code.
  547. func GetAPIError(code ErrorCode) APIError {
  548. return errorCodeResponse[code]
  549. }