-
Notifications
You must be signed in to change notification settings - Fork 29
Fix reading hdf5 attachments with absolute paths without scheme file:// #8832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Warning Rate limit exceeded@fm3 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 13 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change fixes a bug that prevented reading HDF5 attachments with absolute paths lacking the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
unreleased_changes/8832.md
(1 hunks)webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala
(1 hunks)webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/mapping/Hdf5AgglomerateService.scala
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: frcroth
PR: scalableminds/webknossos#8598
File: webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala:89-95
Timestamp: 2025-06-02T09:49:51.047Z
Learning: In WebKnossos dataset layer attachments, multiple file types can safely use the same directory name (like "agglomerates") because the scanning logic filters by file extension. For example, AgglomerateFileInfo scans for .hdf5 files while CumsumFileInfo scans for .json files in the same "agglomerates" directory without interference.
📚 Learning: in webknossos dataset layer attachments, multiple file types can safely use the same directory name ...
Learnt from: frcroth
PR: scalableminds/webknossos#8598
File: webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala:89-95
Timestamp: 2025-06-02T09:49:51.047Z
Learning: In WebKnossos dataset layer attachments, multiple file types can safely use the same directory name (like "agglomerates") because the scanning logic filters by file extension. For example, AgglomerateFileInfo scans for .hdf5 files while CumsumFileInfo scans for .json files in the same "agglomerates" directory without interference.
Applied to files:
unreleased_changes/8832.md
webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/mapping/Hdf5AgglomerateService.scala
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-smoketest-push
- GitHub Check: backend-tests
🔇 Additional comments (2)
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/mapping/Hdf5AgglomerateService.scala (1)
266-266
: LGTM! Proper usage of the fixed localPath method.The change correctly utilizes the updated
localPath
method fromLayerAttachment
to resolve the cumsum.json file path. This ensures consistent and correct path handling for HDF5 attachments, especially those with absolute paths lacking thefile://
prefix.unreleased_changes/8832.md (1)
1-2
: LGTM! Clear and accurate changelog entry.The description accurately captures the bug fix, providing users with a clear understanding of what was resolved. The entry appropriately explains that HDF5 attachments with absolute paths lacking the
file://
prefix are now readable.
if (path.getScheme == null) { | ||
Path.of(path.toString) | ||
} else { | ||
Path.of(path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
LGTM! The URI scheme handling fix looks correct.
The change properly addresses the bug by handling URIs with null schemes (absolute paths without file://
prefix) by converting them to strings before creating a Path. This maintains backward compatibility while fixing the reported issue.
Consider testing edge cases to ensure robustness:
🏁 Script executed:
#!/bin/bash
# Verify that the Path.of behavior works correctly for various URI formats
# Look for existing tests that might cover these scenarios
rg -A 10 -B 5 "localPath|Path\.of" --type scala
Length of output: 74815
Approve URI scheme handling in localPath; add unit tests for edge cases
The conditional correctly covers both “no scheme” URIs (absolute paths without file://
) and preserves original behavior for file://
URIs, while rejecting remote schemes. To ensure full coverage, please add unit tests for the following scenarios in a new DatasetLayerAttachmentsSpec
(or similar):
- URI with null scheme (e.g.
new URI("/absolute/path/data.h5")
) →localPath
returnsPath.of(path.toString)
- URI with explicit file scheme (e.g.
new URI("file:///absolute/path/data.h5")
) →localPath
returnsPath.of(uri)
- URI with non-file scheme (e.g.
new URI("http://example.com/data.h5")
) →localPath
throws an exception - (Optional) Relative URI literal (e.g.
new URI("data/data.h5")
) if you expect to support it
Example test stub:
"localPath" should {
"handle null scheme URIs as absolute paths" in {
val uri = new URI("/tmp/foo.h5")
val attachment = LayerAttachment("foo", uri, LayerAttachmentDataformat.HDF5)
attachment.localPath shouldBe Path.of(uri.toString)
}
"handle file:// URIs correctly" in {
val uri = new URI("file:///tmp/foo.h5")
val attachment = LayerAttachment("foo", uri, LayerAttachmentDataformat.HDF5)
attachment.localPath shouldBe Path.of(uri)
}
"reject non-file schemes" in {
val uri = new URI("http://example.com/foo.h5")
val attachment = LayerAttachment("foo", uri, LayerAttachmentDataformat.HDF5)
an [Exception] should be thrownBy attachment.localPath
}
}
🤖 Prompt for AI Agents
In
webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala
around lines 49 to 53, the URI scheme handling logic is correct but lacks unit
test coverage. Add a new test suite named DatasetLayerAttachmentsSpec (or
similar) with tests covering: URIs with null scheme returning
Path.of(path.toString), URIs with explicit file scheme returning Path.of(uri),
and URIs with non-file schemes throwing an exception. Optionally, include tests
for relative URI literals if supported. Implement these tests to ensure all edge
cases are properly validated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me
Fixed a bug where hdf5 attachments explicitly mentioned in the datasource-properties.json would not be readable if they have an absolute path but no
file://
prefix.These URI/path/string/VaultPath/remoteSourceDescriptor conversions are no fun. We need to refactor this into a unified solution. #8762
Steps to test:
file://
prefixIssues:
$PR_NUMBER.md
file inunreleased_changes
or use./tools/create-changelog-entry.py
)