Skip to content

Conversation

@sanjaikumar-bruno
Copy link
Member

@sanjaikumar-bruno sanjaikumar-bruno commented Jan 28, 2026

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes
    • Preserves and surfaces partial test results when pre-request, test, or post-response scripts fail.
    • Ensures final per-request status reflects all assertions and script outcomes (pass/fail shown consistently).
  • Refactor
    • Standardized script execution and error handling so test results and status reporting are uniform across runs.

✏️ Tip: You can customize this high-level summary in your review settings.

KaranPradhan266 and others added 5 commits January 28, 2026 15:53
…l results for pre-request and post-response scripts across CLI and Electron. This ensures that tests passing before an error are still reported.
… assertion results. This adds clear visual feedback for pass/fail outcomes in the CLI output.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

Centralizes script execution error handling across pre-request, post-response, and test scripts, preserves and surfaces partialResults from script errors, and computes a unified per-request status by aggregating failures across all test phases.

Changes

Cohort / File(s) Summary
CLI runner (request flow)
packages/bruno-cli/src/runner/run-single-request.js
Adds try/catch around pre-request, post-response, and test script execution; preserves partialResults on errors, appends descriptive script-error test entries, supports skip/stop/nextRequest propagation, and computes a consolidated requestStatus from all test phases.
IPC / Electron bridging
packages/bruno-electron/src/ipc/network/index.js
Adds appendScriptErrorResult() helper and integrates partial-results propagation for pre-request, post-response, and test script errors (request and folder runs), ensuring UI events receive partial test results when script errors occur.
Runtime (script execution)
packages/bruno-js/src/runtime/script-runtime.js
Refactors nodevm/quickjs branches to use centralized result builders (buildRequestScriptResult, buildResponseScriptResult), wraps execution in try/catch to attach partialResults on error, and returns consistent result shapes on success or error.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Runner
    participant IPC as IPC / UI
    participant Runtime as Script Runtime
    participant Status as Status Computer

    User->>CLI: trigger request run
    CLI->>Runtime: run pre-request script
    alt pre-request succeeds
        Runtime-->>CLI: pre-request results
    else pre-request errors (with partialResults)
        Runtime-->>CLI: error + partialResults
        CLI->>IPC: emit pre-request results (partial)
    end

    CLI->>Runtime: run main request -> response
    Runtime-->>CLI: response

    CLI->>Runtime: run post-response script
    alt post-response succeeds
        Runtime-->>CLI: post-response results
    else post-response errors (with partialResults)
        Runtime-->>CLI: error + partialResults
        CLI->>IPC: emit post-response results (partial)
    end

    CLI->>Runtime: run test scripts
    alt tests succeed
        Runtime-->>CLI: test results
    else tests error (with partialResults)
        Runtime-->>CLI: error + partialResults
        CLI->>IPC: emit test results (partial)
    end

    CLI->>Status: aggregate pre/post/test/assertions
    Status-->>CLI: consolidated requestStatus (pass|fail)
    CLI-->>User: final result with unified status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🧪 Scripts trip, then hand back a clue,
Partial truths kept when errors ensue,
Runtimes whisper what tests had begun,
Runner collects them, decides if we've won,
Green or red, the final line is true.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references script error detection and fixes, which aligns with the core changes across all three modified files that focus on improved error handling in pre-request, post-response, and test script execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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
Contributor

@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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/bruno-cli/src/runner/run-single-request.js`:
- Around line 801-821: Remove the stray literal 'tomato' from the failure branch
console.log so the output shows only the colored filename and metadata; locate
the block that computes hasAnyFailures/requestStatus and the subsequent if
(hasAnyFailures) console.log call (uses relativeItemPathname, stripExtension,
chalk, response, responseTime) and delete the 'tomato' string so the failure
message mirrors the success branch but with chalk.red for the filename.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants