You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by su...@apache.org on 2023/04/24 13:45:57 UTC
[incubator-opendal] branch update-err-name updated (d1a7bc30 -> a7064b5f)
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a change to branch update-err-name
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
discard d1a7bc30 update PreconditionFailed to ConditionNotMatch
new a7064b5f update PreconditionFailed to ConditionNotMatch
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (d1a7bc30)
\
N -- N -- N refs/heads/update-err-name (a7064b5f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
core/src/types/error.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[incubator-opendal] 01/01: update PreconditionFailed to ConditionNotMatch
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a commit to branch update-err-name
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit a7064b5fad91c7966df4f10af46b14db44803ab8
Author: suyanhanx <su...@gmail.com>
AuthorDate: Mon Apr 24 21:40:07 2023 +0800
update PreconditionFailed to ConditionNotMatch
Signed-off-by: suyanhanx <su...@gmail.com>
---
core/src/services/azblob/error.rs | 2 +-
core/src/services/azdfs/error.rs | 2 +-
core/src/services/gcs/error.rs | 2 +-
core/src/services/http/error.rs | 2 +-
core/src/services/obs/error.rs | 2 +-
core/src/services/oss/error.rs | 2 +-
core/src/services/s3/error.rs | 3 ++-
core/src/services/wasabi/error.rs | 2 +-
core/src/types/error.rs | 16 +++++++++++-----
core/tests/behavior/write.rs | 8 ++++----
10 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/core/src/services/azblob/error.rs b/core/src/services/azblob/error.rs
index 9b52cc4f..c73e956b 100644
--- a/core/src/services/azblob/error.rs
+++ b/core/src/services/azblob/error.rs
@@ -90,7 +90,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/azdfs/error.rs b/core/src/services/azdfs/error.rs
index 3b6d2701..9acc8163 100644
--- a/core/src/services/azdfs/error.rs
+++ b/core/src/services/azdfs/error.rs
@@ -68,7 +68,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/gcs/error.rs b/core/src/services/gcs/error.rs
index efe19868..0f8e262d 100644
--- a/core/src/services/gcs/error.rs
+++ b/core/src/services/gcs/error.rs
@@ -57,7 +57,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/http/error.rs b/core/src/services/http/error.rs
index 5794b8ae..e330e572 100644
--- a/core/src/services/http/error.rs
+++ b/core/src/services/http/error.rs
@@ -31,7 +31,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/obs/error.rs b/core/src/services/obs/error.rs
index 7573157a..3bf328a9 100644
--- a/core/src/services/obs/error.rs
+++ b/core/src/services/obs/error.rs
@@ -45,7 +45,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/oss/error.rs b/core/src/services/oss/error.rs
index a352af70..4e86245f 100644
--- a/core/src/services/oss/error.rs
+++ b/core/src/services/oss/error.rs
@@ -44,7 +44,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/s3/error.rs b/core/src/services/s3/error.rs
index 89f8c522..46a54ec2 100644
--- a/core/src/services/s3/error.rs
+++ b/core/src/services/s3/error.rs
@@ -44,7 +44,8 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (mut kind, mut retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED
+ | StatusCode::NOT_MODIFIED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/wasabi/error.rs b/core/src/services/wasabi/error.rs
index 1eb5407e..04574c9b 100644
--- a/core/src/services/wasabi/error.rs
+++ b/core/src/services/wasabi/error.rs
@@ -44,7 +44,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
let (mut kind, mut retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
- StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/types/error.rs b/core/src/types/error.rs
index 6317b5d7..88453c77 100644
--- a/core/src/types/error.rs
+++ b/core/src/types/error.rs
@@ -70,11 +70,17 @@ pub enum ErrorKind {
RateLimited,
/// The given file paths are same.
IsSameFile,
- /// The preconfition of this operation is not met.
+ /// The condition of this operation is not match.
///
- /// For example, reading a file with If-Match header but the file's ETag
- /// is not match.
- PreconditionFailed,
+ /// The `condition` itself is context based.
+ ///
+ /// For example, in S3, the `condition` can be:
+ /// 1. writing a file with If-Match header but the file's ETag is not match (will get a 412 Precondition Failed).
+ /// 2. reading a file with If-None-Match header but the file's ETag is match (will get a 304 Not Modified).
+ ///
+ /// As OpenDAL cannot handle the `condition not match` error, it will always return this error to users.
+ /// So users could to handle this error by themselves.
+ ConditionNotMatch,
/// The content is truncated.
///
/// This error kind means there are more content to come but been truncated.
@@ -121,7 +127,7 @@ impl From<ErrorKind> for &'static str {
ErrorKind::AlreadyExists => "AlreadyExists",
ErrorKind::RateLimited => "RateLimited",
ErrorKind::IsSameFile => "IsSameFile",
- ErrorKind::PreconditionFailed => "PreconditionFailed",
+ ErrorKind::ConditionNotMatch => "ConditionNotMatch",
ErrorKind::ContentTruncated => "ContentTruncated",
ErrorKind::ContentIncomplete => "ContentIncomplete",
}
diff --git a/core/tests/behavior/write.rs b/core/tests/behavior/write.rs
index 39a6d98d..6a2b66dd 100644
--- a/core/tests/behavior/write.rs
+++ b/core/tests/behavior/write.rs
@@ -248,7 +248,7 @@ pub async fn test_stat_not_exist(op: Operator) -> Result<()> {
Ok(())
}
-/// Stat with if_match should succeed, else get a 412(PreconditionFailed) error.
+/// Stat with if_match should succeed, else get a ConditionNotMatch error.
pub async fn test_stat_with_if_match(op: Operator) -> Result<()> {
if !op.info().capability().stat_with_if_match {
return Ok(());
@@ -271,7 +271,7 @@ pub async fn test_stat_with_if_match(op: Operator) -> Result<()> {
let res = op.stat_with(&path, op_stat).await;
assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind(), ErrorKind::PreconditionFailed);
+ assert_eq!(res.unwrap_err().kind(), ErrorKind::ConditionNotMatch);
let mut op_stat = OpStat::default();
op_stat = op_stat.with_if_match(meta.etag().expect("etag must exist"));
@@ -471,7 +471,7 @@ pub async fn test_read_not_exist(op: Operator) -> Result<()> {
Ok(())
}
-// Read with if_match should match, else get a 412(Precondition Failed) error.
+// Read with if_match should match, else get a ConditionNotMatch error.
pub async fn test_read_with_if_match(op: Operator) -> Result<()> {
if !op.info().capability().read_with_if_match {
return Ok(());
@@ -492,7 +492,7 @@ pub async fn test_read_with_if_match(op: Operator) -> Result<()> {
let res = op.read_with(&path, op_if_match).await;
assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind(), ErrorKind::PreconditionFailed);
+ assert_eq!(res.unwrap_err().kind(), ErrorKind::ConditionNotMatch);
let mut op_if_match = OpRead::default();
op_if_match = op_if_match.with_if_match(meta.etag().expect("etag must exist"));