Xuanwo commented on code in PR #2644: URL: https://github.com/apache/incubator-opendal/pull/2644#discussion_r1263860968
########## core/tests/behavior/write.rs: ########## @@ -1233,3 +1234,31 @@ pub async fn test_fuzz_unsized_writer(op: Operator) -> Result<()> { op.delete(&path).await.expect("delete must succeed"); Ok(()) } + +/// seeking a negative position should return a InvalidInput error +pub async fn test_invalid_reader_seek(op: Operator) -> Result<()> { + let path = uuid::Uuid::new_v4().to_string(); + debug!("Generate a random file: {}", &path); + let (content, _) = gen_bytes(); + + op.write(&path, content.clone()) + .await + .expect("write must succeed"); + + let mut r = op.reader(&path).await?; + let res = r.seek(std::io::SeekFrom::Current(-1024)).await; + + assert!(res.is_err()); + + // the res should be a std::io::Error, which contains a ErrorKind::InvalidInput Review Comment: The problem happens here: https://github.com/apache/incubator-opendal/blob/11eb50fb67bb35c203a6d1e009429c6a7afd751f/core/src/raw/oio/read.rs#L164-L174 We convert all `opendal::Error` into `std::io::Error` with `std::io::ErrorKind::Interrupted` directly which is wrong. Instead, we should implement a `convert_to_io_error(err: opendal::Error) -> std::io::Error` so we can return the correct `std::io::Error` to our users. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@opendal.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org