Should return error with more detail for `validate_path`
context: https://discord.com/channels/1081052318650339399/1081052319342407715/1087747871656390807
when using Operator.list, we check whether the input is dir by detecting the tailing /,
it is documented here https://github.com/apache/incubator-opendal/blob/main/core/src/types/operator/operator.rs#L786,
but it still is easy to be ignored.
as the context discussed, we could enhance the Error to improve the readability.
possible solution:
- add a new type like
UnexpectedPathorInvalidPath - add more detail to the
NotADirectoryerror
after checking the code, We already had error messages with the error type, we could let the validate_path https://github.com/apache/incubator-opendal/blob/04ca6e5c29f5ddd637f4633f987fe7f5eadc3751/core/src/raw/path.rs#L215 return specific error, so that we can know the details
WDYT @Xuanwo
- add more detail to the
NotADirectoryerror
We can start from this way first!
https://github.com/apache/incubator-opendal/blob/04ca6e5c29f5ddd637f4633f987fe7f5eadc3751/core/src/types/operator/blocking_operator.rs#L296-L303
Adding more accurate message instead of read path is not a directory will be helpful.
@Xuanwo the only difference is error message?
@Xuanwo the only difference is error message?
ErrorKind, operation are also different.
did I misunderstand you? @Xuanwo
it looks like the 2 have the same ErrorKind, NotADirectory and operation is meant to be different, one for list and the other create_dir
https://github.com/apache/incubator-opendal/blob/04ca6e5c29f5ddd637f4633f987fe7f5eadc3751/core/src/types/operator/blocking_operator.rs#L296-L303
https://github.com/apache/incubator-opendal/blob/524b7870878a91bf072283477f11cf317e212fce/core/src/types/operator/operator.rs#L818-L826
The discussion seems to be going in the wrong direction. We want to inform our users that the error (NotADirectory or IsADirectory) is caused by an incorrect input path. We can modify the error description to improve its clarity and effectiveness.
yes, that's what I expecting, how about
the path trying to list should end with `/`
as ErrorKind::NotADirectory has shown the meaning not a directory
Great!