Skip to content

Fix CLI availability check for CI environments#93

Merged
orpiske merged 1 commit into
wanaku-ai:mainfrom
orpiske:quick-fix/cli-availability-check
Apr 29, 2026
Merged

Fix CLI availability check for CI environments#93
orpiske merged 1 commit into
wanaku-ai:mainfrom
orpiske:quick-fix/cli-availability-check

Conversation

@orpiske
Copy link
Copy Markdown
Contributor

@orpiske orpiske commented Apr 29, 2026

Summary

  • Fix CLIExecutor.isAvailable() returning false when the CLI is installed but --version output goes to /dev/tty instead of stdout
  • The --plain flag is not appended for flags starting with -, so version output may not be captured in stdout/stderr
  • Combined with Quarkus picocli returning exit code 1 for --version, the old check (!output.isEmpty() || exitCode == 0) failed
  • Now treats any exit code other than -1 (our sentinel for IOException/timeout) as "CLI is available"

Test plan

  • Verify HttpToolCliITCase tests pass in CI
  • Verify tests still skip/fail gracefully when CLI binary is genuinely missing

Summary by Sourcery

Update CLI availability check logic to treat any non-sentinel exit code as indicating a present and executable CLI binary.

Bug Fixes:

  • Fix false negatives in CLI availability detection when the CLI returns a non-zero exit code or writes version output outside of captured stdout/stderr.

Enhancements:

  • Add diagnostic logging when the CLI is not available or when the availability check itself fails.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the CLI availability check to rely solely on the process exit code sentinel (-1) instead of parsing version output or requiring a zero exit code, and adds logging for unavailable or failing CLI checks.

File-Level Changes

Change Details Files
Simplified CLI availability logic to treat any non -1 exit code as available and added logging for unavailable CLI or exceptions during the check.
  • Replace mixed output/exit-code based availability condition with a single check that the exit code is not -1
  • Log a warning with CLI path and combined output when the CLI is deemed unavailable due to exit code -1
  • Log a warning with the exception message when the availability check itself throws an exception
  • Update Javadoc to document the -1 sentinel semantics and explain why non-zero exit codes still imply availability
test-common/src/main/java/ai/wanaku/test/client/CLIExecutor.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider avoiding the magic -1 exit code by extracting it into a named constant or enum in CLIResult/CLIExecutor so the sentinel behavior is easier to understand and reuse.
  • The LOG.warn when availability fails would be more actionable if it included the exit code and not just the combined output or exception message, to help distinguish between different failure modes.
  • Catching a broad Exception in isAvailable() may hide programming errors; if possible, narrow this to the specific process/IO-related exceptions that should map to false for availability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider avoiding the magic `-1` exit code by extracting it into a named constant or enum in `CLIResult`/`CLIExecutor` so the sentinel behavior is easier to understand and reuse.
- The `LOG.warn` when availability fails would be more actionable if it included the exit code and not just the combined output or exception message, to help distinguish between different failure modes.
- Catching a broad `Exception` in `isAvailable()` may hide programming errors; if possible, narrow this to the specific process/IO-related exceptions that should map to `false` for availability.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

For JAR-based CLIs, check file existence instead of spawning a
--version subprocess. The subprocess is unreliable because Quarkus
picocli returns exit code 1 for --version and JLine may redirect
output to /dev/tty, leaving stdout/stderr empty.
@orpiske orpiske force-pushed the quick-fix/cli-availability-check branch from b6b3a18 to e7c37f6 Compare April 29, 2026 09:55
@orpiske orpiske merged commit b8a49d8 into wanaku-ai:main Apr 29, 2026
2 checks 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.

1 participant