Add FileSystemErrorDetector for file system error detection#7
Conversation
Detects: - FileNotFoundException - AccessDeniedException - No such file or directory - Permission denied Severity: ERROR Good first issue contribution.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 45 seconds. ⌛ 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. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/com/stacklens/detector/AllDetectorsTest.java (1)
165-193: Consider asserting issue type in every positive case.Only
fileSystemErrorDetector_detectsFileNotFoundExceptionverifiesgetType()equals"FileSystemException". The other three positive cases only checkisPresent(), which would still pass if any detector ordering change caused another detector to claim the line first (e.g., a future auth detector matching"Permission denied"). Asserting the type in each case makes the tests more regression-resistant.Proposed tightening
- Optional<Issue> result = detector.detect(line); - - assertTrue(result.isPresent()); + Optional<Issue> result = detector.detect(line); + + assertTrue(result.isPresent()); + assertEquals("FileSystemException", result.get().getType());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/stacklens/detector/AllDetectorsTest.java` around lines 165 - 193, Update each positive test to assert the detected Issue has the expected type: in fileSystemErrorDetector_detectsAccessDeniedException, fileSystemErrorDetector_detectsNoSuchFileOrDirectory, and fileSystemErrorDetector_detectsPermissionDenied call result.get().getType() and assert it equals "FileSystemException" (or the exact string used by FileSystemErrorDetector) after assertTrue(result.isPresent()) so the tests fail if another detector claims the line.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/com/stacklens/detector/FileSystemErrorDetector.java`:
- Around line 21-24: The FileSystemErrorDetector currently uses broad,
case-sensitive substring checks which cause false positives (e.g., "Permission
denied" in DB/auth logs); update its matching logic to be case-insensitive and
require co-occurrence of a filesystem signal before classifying: for example,
only treat "permission denied" or "no such file or directory" as filesystem
errors when the same line also contains a path token ("/" or "\" or a
drive-letter pattern), an explicit IOException/FileSystemException token, or a
parenthetical "(No such file or directory)". Modify the checks in
FileSystemErrorDetector (the method performing the line.contains checks) to use
normalized case or regex and require both the generic phrase and one filesystem
indicator before returning a match; leave IssueClassifier registration order
unchanged.
---
Nitpick comments:
In `@src/test/java/com/stacklens/detector/AllDetectorsTest.java`:
- Around line 165-193: Update each positive test to assert the detected Issue
has the expected type: in fileSystemErrorDetector_detectsAccessDeniedException,
fileSystemErrorDetector_detectsNoSuchFileOrDirectory, and
fileSystemErrorDetector_detectsPermissionDenied call result.get().getType() and
assert it equals "FileSystemException" (or the exact string used by
FileSystemErrorDetector) after assertTrue(result.isPresent()) so the tests fail
if another detector claims the line.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b009f129-23e8-4278-b70e-bce101371a2f
⛔ Files ignored due to path filters (1)
samples/sample-filesystem-error.logis excluded by!**/*.log
📒 Files selected for processing (3)
src/main/java/com/stacklens/classifier/IssueClassifier.javasrc/main/java/com/stacklens/detector/FileSystemErrorDetector.javasrc/test/java/com/stacklens/detector/AllDetectorsTest.java
…stem context - Add case-insensitive check for 'permission denied' using toLowerCase() - Require filesystem signal (java.io, / or \) to avoid false positives from PostgreSQL or SSH auth errors
Closes #3
Added FileSystemErrorDetector to detect common file system errors
in Java/Spring Boot logs including FileNotFoundException,
AccessDeniedException, "No such file or directory", and
"Permission denied".
Changes:
Summary by CodeRabbit
Release Notes