Skip to content

Operator: Fix error output and prevent silent failures in next command - #307

Open
matta wants to merge 1 commit into
mainfrom
operator-ux-improvements-7910046922314857452
Open

Operator: Fix error output and prevent silent failures in next command#307
matta wants to merge 1 commit into
mainfrom
operator-ux-improvements-7910046922314857452

Conversation

@matta

@matta matta commented Mar 17, 2026

Copy link
Copy Markdown
Owner

Addresses two key UX issues:

  1. pebble next --json returned {"tasks":[]} and exited with code 0 when no tasks were found. This violated the rule to consistently use exit code > 0 for missing items to prevent silent failures in automated scripts.
  2. The default error handler in main.rs used the Debug formatter ({:?}), which dumped noisy stack traces with ANSI color escapes directly to stderr. This made error parsing difficult and intimidating. It has been replaced with the standard Display formatter ({}) prefixed with error: .

PR created automatically by Jules for task 7910046922314857452 started by @matta

…t` command

- Change error formatting in `main.rs` to use `{}` with `error: ` prefix instead of verbose `{:?}` stack traces, making output parseable for agents and clean for humans.
- Reorder `tasks.is_empty()` check in `next` command to properly return `NotFoundError` and exit code 1 even when `--json` is provided, preventing silent failures.
- Update relevant integration tests in `cli_check.rs` and `cli_json.rs` to expect the new formatting and behavior.

Co-authored-by: matta <37314+matta@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@trunk-io

trunk-io Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience and reliability of the pebble CLI tool by addressing two critical issues related to error handling and command output. It standardizes error messages for better readability and machine parsing, and corrects the exit code behavior of the next command when no results are found, ensuring that automation scripts can reliably detect and react to the absence of tasks.

Highlights

  • Improved Error Output: The application's error messages printed to stderr have been standardized. Previously, verbose Debug formatter output with stack traces and ANSI color escapes was used, making errors difficult to parse. Now, all errors use the Display formatter ({}) and are prefixed with error: for cleaner, more consistent output.
  • Corrected pebble next --json Exit Code: The pebble next --json command previously returned an exit code of 0 and an empty JSON array ({"tasks":[]}) when no tasks were found. This behavior has been corrected to return a non-zero exit code (specifically, an NotFoundError) in such cases, aligning with standard CLI practices for indicating missing items and preventing silent failures in automated scripts.
Changelog
  • .jules/operator.md
    • Documented the new standard for error output using Display formatting and error: prefix.
    • Documented the standard for NotFoundError to be returned before checking --json for retrieval commands.
  • crates/pebble/src/commands.rs
    • Moved the tasks.is_empty() check in run_next to occur before the ctx.json block.
    • Ensured that NotFoundError is returned when no tasks are found, even if --json is specified.
  • crates/pebble/src/main.rs
    • Removed the import for NotFoundError as it's no longer handled separately in main.
    • Unified error output in main to use eprintln!("error: {}", err); for all error types, including UsageError and general runtime errors.
    • Removed the specific eprintln!("Runtime error: {:?}", err); which used Debug formatting.
  • crates/pebble/tests/integration/cli_check.rs
    • Updated assert_issue_stderr to check for "error:" instead of "Runtime error:" in stderr.
    • Updated test_check_modes_issue_json_payload_is_identical to check for "error:" instead of "Runtime error:" in stderr.
  • crates/pebble/tests/integration/cli_json.rs
    • Added write_task to test_next_json_stdout_only to ensure a task exists for the test.
    • Updated the assertion in test_next_json_stdout_only to expect 1 task instead of 0.
Activity
  • PR created automatically by Jules for task 7910046922314857452 started by @matta.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request standardizes error output and exit codes across the pebble CLI. It updates the operator.md documentation to reflect new guidelines for error formatting and non-zero exit codes for search commands that find no results. Specifically, the run_next command now returns a NotFoundError with a non-zero exit code if no tasks are found, even when --json is used, addressing a silent failure anti-pattern. Error handling in main.rs is refactored to consistently print error: <message> to stderr, removing verbose debug output. Corresponding integration tests have been updated to assert against the new standardized error messages and the expected JSON output for the next command.

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