errors.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package v2
  2. import (
  3. "net/http"
  4. "github.com/docker/distribution/registry/api/errcode"
  5. )
  6. const errGroup = "registry.api.v2"
  7. var (
  8. // ErrorCodeDigestInvalid is returned when uploading a blob if the
  9. // provided digest does not match the blob contents.
  10. ErrorCodeDigestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  11. Value: "DIGEST_INVALID",
  12. Message: "provided digest did not match uploaded content",
  13. Description: `When a blob is uploaded, the registry will check that
  14. the content matches the digest provided by the client. The error may
  15. include a detail structure with the key "digest", including the
  16. invalid digest string. This error may also be returned when a manifest
  17. includes an invalid layer digest.`,
  18. HTTPStatusCode: http.StatusBadRequest,
  19. })
  20. // ErrorCodeSizeInvalid is returned when uploading a blob if the provided
  21. ErrorCodeSizeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  22. Value: "SIZE_INVALID",
  23. Message: "provided length did not match content length",
  24. Description: `When a layer is uploaded, the provided size will be
  25. checked against the uploaded content. If they do not match, this error
  26. will be returned.`,
  27. HTTPStatusCode: http.StatusBadRequest,
  28. })
  29. // ErrorCodeNameInvalid is returned when the name in the manifest does not
  30. // match the provided name.
  31. ErrorCodeNameInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  32. Value: "NAME_INVALID",
  33. Message: "invalid repository name",
  34. Description: `Invalid repository name encountered either during
  35. manifest validation or any API operation.`,
  36. HTTPStatusCode: http.StatusBadRequest,
  37. })
  38. // ErrorCodeTagInvalid is returned when the tag in the manifest does not
  39. // match the provided tag.
  40. ErrorCodeTagInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  41. Value: "TAG_INVALID",
  42. Message: "manifest tag did not match URI",
  43. Description: `During a manifest upload, if the tag in the manifest
  44. does not match the uri tag, this error will be returned.`,
  45. HTTPStatusCode: http.StatusBadRequest,
  46. })
  47. // ErrorCodeNameUnknown when the repository name is not known.
  48. ErrorCodeNameUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
  49. Value: "NAME_UNKNOWN",
  50. Message: "repository name not known to registry",
  51. Description: `This is returned if the name used during an operation is
  52. unknown to the registry.`,
  53. HTTPStatusCode: http.StatusNotFound,
  54. })
  55. // ErrorCodeManifestUnknown returned when image manifest is unknown.
  56. ErrorCodeManifestUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
  57. Value: "MANIFEST_UNKNOWN",
  58. Message: "manifest unknown",
  59. Description: `This error is returned when the manifest, identified by
  60. name and tag is unknown to the repository.`,
  61. HTTPStatusCode: http.StatusNotFound,
  62. })
  63. // ErrorCodeManifestInvalid returned when an image manifest is invalid,
  64. // typically during a PUT operation. This error encompasses all errors
  65. // encountered during manifest validation that aren't signature errors.
  66. ErrorCodeManifestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  67. Value: "MANIFEST_INVALID",
  68. Message: "manifest invalid",
  69. Description: `During upload, manifests undergo several checks ensuring
  70. validity. If those checks fail, this error may be returned, unless a
  71. more specific error is included. The detail will contain information
  72. the failed validation.`,
  73. HTTPStatusCode: http.StatusBadRequest,
  74. })
  75. // ErrorCodeManifestUnverified is returned when the manifest fails
  76. // signature verification.
  77. ErrorCodeManifestUnverified = errcode.Register(errGroup, errcode.ErrorDescriptor{
  78. Value: "MANIFEST_UNVERIFIED",
  79. Message: "manifest failed signature verification",
  80. Description: `During manifest upload, if the manifest fails signature
  81. verification, this error will be returned.`,
  82. HTTPStatusCode: http.StatusBadRequest,
  83. })
  84. // ErrorCodeManifestBlobUnknown is returned when a manifest blob is
  85. // unknown to the registry.
  86. ErrorCodeManifestBlobUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
  87. Value: "MANIFEST_BLOB_UNKNOWN",
  88. Message: "blob unknown to registry",
  89. Description: `This error may be returned when a manifest blob is
  90. unknown to the registry.`,
  91. HTTPStatusCode: http.StatusBadRequest,
  92. })
  93. // ErrorCodeBlobUnknown is returned when a blob is unknown to the
  94. // registry. This can happen when the manifest references a nonexistent
  95. // layer or the result is not found by a blob fetch.
  96. ErrorCodeBlobUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
  97. Value: "BLOB_UNKNOWN",
  98. Message: "blob unknown to registry",
  99. Description: `This error may be returned when a blob is unknown to the
  100. registry in a specified repository. This can be returned with a
  101. standard get or if a manifest references an unknown layer during
  102. upload.`,
  103. HTTPStatusCode: http.StatusNotFound,
  104. })
  105. // ErrorCodeBlobUploadUnknown is returned when an upload is unknown.
  106. ErrorCodeBlobUploadUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
  107. Value: "BLOB_UPLOAD_UNKNOWN",
  108. Message: "blob upload unknown to registry",
  109. Description: `If a blob upload has been cancelled or was never
  110. started, this error code may be returned.`,
  111. HTTPStatusCode: http.StatusNotFound,
  112. })
  113. // ErrorCodeBlobUploadInvalid is returned when an upload is invalid.
  114. ErrorCodeBlobUploadInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
  115. Value: "BLOB_UPLOAD_INVALID",
  116. Message: "blob upload invalid",
  117. Description: `The blob upload encountered an error and can no
  118. longer proceed.`,
  119. HTTPStatusCode: http.StatusNotFound,
  120. })
  121. )