Copilot commented on code in PR #3311:
URL: https://github.com/apache/iceberg-rust/pull/3311#discussion_r4148642978
##########
crates/storage/opendal/src/azdls.rs:
##########
@@ -237,6 +236,13 @@ impl AzureStoragePath {
self.endpoint_suffix
)
}
+
+ /// The part of `absolute_path` below the filesystem, without a leading
`/`,
+ /// like the relative paths of the other backends.
+ pub(crate) fn relative_path<'a>(&self, absolute_path: &'a str) -> &'a str {
+ let path = &absolute_path[absolute_path.len() - self.path.len()..];
+ path.strip_prefix('/').unwrap_or(path)
Review Comment:
This performs unchecked byte slicing into `absolute_path` based on
`self.path.len()`, which will panic if the provided `absolute_path` doesn't
exactly correspond to `self.path`'s length (e.g., normalization differences or
accidental misuse of the API). Since this is a reusable helper, it should
defensively validate assumptions. Consider (mandatory) changing this helper to
avoid panics by (a) ensuring `absolute_path.ends_with(&self.path)` and deriving
the slice via `strip_suffix`, or (b) using `get(start..)`, and returning a
`Result<&str>` with an explicit error if the expected suffix isn't present.
This makes the invariant explicit and prevents potential production panics.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]