edit-icon download-icon


Last Updated: Dec 22, 2017

Call errors in Go are returned by using a unified error interface. The error interface is defined as follows:

  1. type error interface {
  2. Error() string
  3. }

Other errors are also returned by using this error interface. For example, HTTP request errors are returned as follows:

  1. //net.Error
  2. type Error interface {
  3. error
  4. Timeout() bool // Is the error a time-out
  5. Temporary() bool // Is the error temporary
  6. }

Appropriate errors are returned in case of request errors when OSS Go SDK is used. In case of HTTP request errors and I/O errors, errors preset in Go are returned. In case of request processing error of the OSS Server, the following error is returned. This error is returned by using the error interface.

  1. type ServiceError struct {
  2. Code string // The error code that the OSS returns to the user
  3. Message string // The detailed error information provided by OSS
  4. RequestId string // The UUID that uniquely identifies the request
  5. HostId string // Identify the OSS cluster accessed
  6. StatusCode int // HTTP status code
  7. }

The following error is returned when the HTTP status code returned by the OSS does not conform to the expected one. The error is also returned through the error interface.

  1. type UnexpectedStatusCodeError struct {
  2. allowed []int // The expected HTTP status code returned by the OSS
  3. got int // The actual HTTP status code returned by the OSS
  4. }

OSS error codes

The following table lists the OSS error codes:

Error code Description HTTP status code
AccessDenied The access is denied. 403
BucketAlreadyExists The bucket already exists. 409
BucketNotEmpty The bucket is not empty. 409
EntityTooLarge The entity is too large. 400
EntityTooSmall The entity is too small. 400
FileGroupTooLarge The object group is too large. 400
InvalidLinkName The name of the object link is the same as the linked object. 400
LinkPartNotExist The object to which the object link is linked does not exist. 400
ObjectLinkTooLarge The object link has too many objects. 400
FieldItemTooLong The table field in the post request is too large. 400
FilePartInterity The object part has been changed. 400
FilePartNotExist The object part does not exist. 400
FilePartStale The object part has expired. 400
IncorrectNumberOfFilesInPOSTRequest The number of objects in the post request is incorrect. 400
InvalidArgument The parameter format is invalid. 400
InvalidAccessKeyId The AccessKeyID does not exist. 403
InvalidBucketName The bucket name is invalid. 400
InvalidDigest The digest is invalid. 400
InvalidEncryptionAlgorithmError The specified entropy encryption algorithm is invalid. 400
InvalidObjectName The object name is invalid. 400
InvalidPart The part is invalid. 400
InvalidPartOrder The part order is invalid. 400
InvalidPolicyDocument The policy document is invalid. 400
InvalidTargetBucketForLogging A target bucket for logging is invalid. 400
InternalError An error occurs in OSS. 500
MalformedXML The XML format is invalid. 400
MalformedPOSTRequest The format of the body in the post request is invalid. 400
MaxPOSTPreDataLengthExceededError The body, except the object content, uploaded in the post request is too large. 400
MethodNotAllowed The method is not supported. 405
MissingArgument A parameter is missing. 411
MissingContentLength The content length is missing. 411
NoSuchBucket The bucket does not exist. 404
NoSuchKey The object does not exist. 404
NoSuchUpload The multipart upload ID does not exist. 404
NotImplemented The method cannot be implemented. 501
PreconditionFailed The preconditioning fails. 412
RequestTimeTooSkewed The request initiation time exceeds the server time by 15 minutes. 403
RequestTimeout The request times out. 400
RequestIsNotMultiPartContent The content type in the post request is invalid. 400
SignatureDoesNotMatch The signature is incorrect. 403
TooManyBuckets The number of the user’s buckets exceeds the limit. 400
InvalidEncryptionAlgorithmError The specified entropy encryption algorithm is invalid. 400


  • In the preceding table, the error code is OssServiceError.Code, and the HTTP status code is OssServiceError.StatusCode.

  • If you try to use an operation not supported by the OSS to access a resource, OSS returns the 405 Method Not Allowed error.

Thank you! We've received your feedback.