Skip to content

Fix RevealPathService#109

Merged
infeo merged 3 commits intodevelopfrom
feature/fix-reveal-command
Mar 10, 2026
Merged

Fix RevealPathService#109
infeo merged 3 commits intodevelopfrom
feature/fix-reveal-command

Conversation

@infeo
Copy link
Member

@infeo infeo commented Mar 10, 2026

This PR fixes the macOS specific OpenCmdRevealPathService.

That RevealPathService implementation uses the macOS based open binary. When calling reveal internally the impl constructs a open ... /some/path command and calls it as a subprocess.

The impl contained a bug: If the given path is a directory, the constructed command contained three parameters:

  • open
  • "" (empty string)
  • actual path

It is fixed by constructing the correct command. (not containing the emtpy string)

@infeo infeo added this to the 1.5.0 milestone Mar 10, 2026
@infeo infeo self-assigned this Mar 10, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6abe29c-1cc6-4659-8c06-ae1a0b2e452c

📥 Commits

Reviewing files that changed from the base of the PR and between b717b3e and b0385ee.

📒 Files selected for processing (1)
  • src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java

Walkthrough

This change extracts command construction in OpenCmdRevealPathService into a new private helper createCommandAsList(Path) that checks file attributes with NOFOLLOW_LINKS to decide between ["open", path] for directories and ["open", "-R", path] for files. The process start was replaced with ProcessBuilder.command(cmd).start(). Exit handling and timeout were added: a 5-second wait, reading error stream on non-zero exit to throw RevealFailedException, and finally-forceful process destruction. A java.util.List import was added.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix RevealPathService' directly corresponds to the PR's main objective of fixing a bug in the OpenCmdRevealPathService implementation for macOS path revealing.
Description check ✅ Passed The description clearly explains the bug (empty string parameter in directory commands) and indicates it was fixed by constructing the correct command, which aligns with the changeset modifications.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/fix-reveal-command

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java (1)

24-34: ⚠️ Potential issue | 🟠 Major

Treat waitFor timeout as a failure.

If the open process does not exit within 5 seconds, this method currently returns successfully and leaves the subprocess running. That turns a hung reveal into a silent success.

Suggested fix
 			final var process = new ProcessBuilder().command(cmd).start();
 			try (var reader = process.errorReader()) {
-				if (process.waitFor(5000, TimeUnit.MILLISECONDS)) {
-					int exitValue = process.exitValue();
-					if (process.exitValue() != 0) {
-						String error = reader.lines().collect(Collectors.joining());
-						throw new RevealFailedException("open command exited with value " + exitValue + " and error message: " + error);
-					}
-				}
+				if (!process.waitFor(5000, TimeUnit.MILLISECONDS)) {
+					process.destroyForcibly();
+					throw new RevealFailedException("open command timed out after 5000 ms");
+				}
+				int exitValue = process.exitValue();
+				if (exitValue != 0) {
+					String error = reader.lines().collect(Collectors.joining());
+					throw new RevealFailedException("open command exited with value " + exitValue + " and error message: " + error);
+				}
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java`
around lines 24 - 34, The method in OpenCmdRevealPathService uses
process.waitFor(5000, TimeUnit.MILLISECONDS) but ignores the case when it
returns false, causing a hung subprocess to be treated as success; update the
logic in the block around createCommandAsList(p) / new
ProcessBuilder().command(cmd).start() so that if waitFor(...) returns false you
treat it as a failure: destroy/terminate the process, read any available
error/output via process.errorReader() (and/or inputReader), and throw a
RevealFailedException that indicates the timeout; only call process.exitValue()
when waitFor returned true and use that exit value and collected error text in
the exception message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java`:
- Around line 24-34: The method in OpenCmdRevealPathService uses
process.waitFor(5000, TimeUnit.MILLISECONDS) but ignores the case when it
returns false, causing a hung subprocess to be treated as success; update the
logic in the block around createCommandAsList(p) / new
ProcessBuilder().command(cmd).start() so that if waitFor(...) returns false you
treat it as a failure: destroy/terminate the process, read any available
error/output via process.errorReader() (and/or inputReader), and throw a
RevealFailedException that indicates the timeout; only call process.exitValue()
when waitFor returned true and use that exit value and collected error text in
the exception message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c460ca78-94fa-43f4-b065-a7d00d17577f

📥 Commits

Reviewing files that changed from the base of the PR and between 15ecdf4 and b717b3e.

📒 Files selected for processing (1)
  • src/main/java/org/cryptomator/macos/revealpath/OpenCmdRevealPathService.java

@infeo infeo merged commit 7fcd1b0 into develop Mar 10, 2026
8 checks passed
@infeo infeo deleted the feature/fix-reveal-command branch March 10, 2026 12:03
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.

1 participant