Skip to content

Add FileSystemErrorDetector for file system error detection#7

Merged
AbaSheger merged 3 commits into
AbaSheger:mainfrom
sandeshgorde:main
Apr 25, 2026
Merged

Add FileSystemErrorDetector for file system error detection#7
AbaSheger merged 3 commits into
AbaSheger:mainfrom
sandeshgorde:main

Conversation

@sandeshgorde

@sandeshgorde sandeshgorde commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

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:

  • New detector: FileSystemErrorDetector.java
  • Registered in IssueClassifier
  • Unit tests added
  • Sample log file added to samples/

Summary by CodeRabbit

Release Notes

  • New Features
    • The system now detects filesystem-related errors in application logs, including file not found and permission denied scenarios. Detected errors are flagged with ERROR severity and include remediation suggestions for resolution.

Detects:
- FileNotFoundException
- AccessDeniedException
- No such file or directory
- Permission denied

Severity: ERROR
Good first issue contribution.
@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@sandeshgorde has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 45 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ccc08e5c-4e2b-4db5-84aa-f033ae90a899

📥 Commits

Reviewing files that changed from the base of the PR and between 1670f53 and 5d73556.

📒 Files selected for processing (1)
  • src/main/java/com/stacklens/detector/FileSystemErrorDetector.java
📝 Walkthrough

Walkthrough

A new FileSystemErrorDetector implementation is added to detect filesystem-related errors in log lines by matching specific patterns. The detector is integrated into IssueClassifier and includes comprehensive test coverage validating its detection logic and integration.

Changes

Cohort / File(s) Summary
FileSystemErrorDetector Implementation
src/main/java/com/stacklens/detector/FileSystemErrorDetector.java
New IssueDetector implementation that identifies filesystem errors (FileNotFoundException, AccessDeniedException, "No such file or directory", "Permission denied") and returns issues with severity ERROR and predefined remediation suggestions.
Detector Integration
src/main/java/com/stacklens/classifier/IssueClassifier.java
Registers the new FileSystemErrorDetector in the classifier constructor, adding it to the active detector set for line-by-line error classification.
Test Coverage
src/test/java/com/stacklens/detector/AllDetectorsTest.java
Five new test cases verifying that FileSystemErrorDetector correctly detects filesystem error patterns and returns empty Optional for clean lines.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A detector hops into the fold,
Filesystem whispers, now heard and told,
FileNotFound? Denied access? No fear!
The rabbit's detector makes errors clear,
One line to register, tests prove it's whole! 📁✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a FileSystemErrorDetector for detecting file system errors.
Description check ✅ Passed The description covers the main objective (closes #3), explains what was added, and lists the key changes made, though it omits some template sections like Type of Change and Testing details.
Linked Issues check ✅ Passed All coding requirements from issue #3 are met: FileSystemErrorDetector detects all four specified patterns (FileNotFoundException, AccessDeniedException, 'No such file or directory', 'Permission denied'), implements the detector pattern, sets ERROR severity, and is registered in IssueClassifier.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing FileSystemErrorDetector and its integration; no unrelated or out-of-scope modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sandeshgorde sandeshgorde marked this pull request as ready for review April 18, 2026 10:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_detectsFileNotFoundException verifies getType() equals "FileSystemException". The other three positive cases only check isPresent(), 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

📥 Commits

Reviewing files that changed from the base of the PR and between dfe81fc and 1670f53.

⛔ Files ignored due to path filters (1)
  • samples/sample-filesystem-error.log is excluded by !**/*.log
📒 Files selected for processing (3)
  • src/main/java/com/stacklens/classifier/IssueClassifier.java
  • src/main/java/com/stacklens/detector/FileSystemErrorDetector.java
  • src/test/java/com/stacklens/detector/AllDetectorsTest.java

Comment thread src/main/java/com/stacklens/detector/FileSystemErrorDetector.java Outdated
…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
@AbaSheger AbaSheger merged commit f69d66a into AbaSheger:main Apr 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detector] Add file system error detection

2 participants