Skip to content

Fix/runner results enhancement - #7040

Merged
bijin-bruno merged 2 commits into
usebruno:mainfrom
sanjaikumar-bruno:fix/runner-results-enhancement
Feb 4, 2026
Merged

bijin-bruno merged 2 commits into
usebruno:mainfrom
sanjaikumar-bruno:fix/runner-results-enhancement

Conversation

@sanjaikumar-bruno

@sanjaikumar-bruno sanjaikumar-bruno commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

BRU-2249

This PR builds on and replaces #6261 ("Mark test script errors as failed in runner") with additional fixes and a clearer approach to script errors in the runner.

Fixes: #6258

* Mark test script errors as failed in runner
    and CLI

* Unify handling of post-response and pre-request script errors in both CLI and Electron

* feat: Enhance error handling in script execution by preserving partial results for pre-request and post-response scripts across CLI and Electron. This ensures that tests passing before an error are still reported.

* Preserving stopExecution in test script error handler

---------

Co-authored-by: Pragadesh-45 <[email protected]>
@coderabbitai

coderabbitai Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds try/catch around pre-request, post-response, and test script execution to preserve and propagate partial script results and control signals; introduces isScriptError on test results, centralizes script-error augmentation, and updates aggregation to treat script errors as failures while excluding them from test counts.

Changes

Cohort / File(s) Summary
Core Runner Orchestration
packages/bruno-cli/src/runner/run-single-request.js
Wraps pre-request/post-response/test script runs in try/catch; handles skipRequest, returns structured skipped/error responses, preserves/propagates partialResults, nextRequestName, and stopExecution, and logs script test results.
Type Definitions
packages/bruno-common/src/runner/types/index.ts
Adds optional isScriptError?: boolean to T_TestPassResult and T_TestFailResult to mark entries produced by script-execution failures.
Result Aggregation
packages/bruno-common/src/runner/runner-summary.ts
Filters out isScriptError entries from test counts, treats script errors as failures (sets anyFailed), and adjusts per-result aggregation for passed/failed/error/skipped requests.
Runtime Execution
packages/bruno-js/src/runtime/script-runtime.js
Introduces buildRequestScriptResult/buildResponseScriptResult helpers; wraps NodeVM and QuickJS execution in try/catch to attach partialResults on errors and return consistent result objects.
IPC Layer
packages/bruno-electron/src/ipc/network/index.js
Adds local appendScriptErrorResult helper to merge script-error entries into results and ensure partial results are surfaced to the UI (emitted test results, notifications, cookie updates).

Sequence Diagram(s)

sequenceDiagram
    actor Runner
    participant ScriptRuntime
    participant Network as "Network / HTTP"
    participant IPC as "IPC / Electron UI"

    Runner->>ScriptRuntime: run pre-request script
    alt pre-request throws OR returns skipRequest
        ScriptRuntime-->>Runner: partialResults / skipRequest
        Runner->>IPC: emit pre-request test results (include partialResults, isScriptError)
        Runner-->>Runner: return skipped or error result (no HTTP sent)
    else pre-request succeeds
        ScriptRuntime-->>Runner: preRequestTestResults
        Runner->>Network: perform HTTP request
        Network-->>Runner: response
        Runner->>ScriptRuntime: run post-response script
        alt post-response throws
            ScriptRuntime-->>Runner: partialResults
            Runner->>IPC: emit post-response partial results (isScriptError)
            Runner-->>Runner: return error result
        else post-response succeeds
            ScriptRuntime-->>Runner: postResponseTestResults
            Runner->>ScriptRuntime: run test scripts
            ScriptRuntime-->>Runner: testResults (may include partialResults/isScriptError)
            Runner->>IPC: emit final results (tests, cookies, notifications)
            Runner-->>Runner: return completed result
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • Pragadesh44-Bruno

Poem

🧪 A script may trip, a test may sigh,
We catch the pieces, keep the why.
Partial echoes, flags that gleam,
Results now tell the whole small seam,
Logs sing true — the runner's eye. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title describes a broad enhancement to runner results but doesn't clearly communicate the primary change: handling script errors as failures with partial result propagation. Consider a more specific title like 'Handle script errors as failures with partial results' or 'Propagate partial results from script errors in runner' to clarify the main objective.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

bijin-bruno
bijin-bruno previously approved these changes Feb 4, 2026

@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: 2

🤖 Fix all issues with AI agents
In `@packages/bruno-common/src/runner/runner-summary.ts`:
- Around line 26-29: The pre-request aggregation is counting failures even for
entries with isScriptError, causing failedPreRequestTests to potentially exceed
totalPreRequestTests; update the pre-request aggregation logic that updates
failedPreRequestTests (and any failedPreRequestAssertions) to only increment
when the record has !isScriptError (use the same filter used for
totalPreRequestTests: preRequestTestResults?.filter(r => !r.isScriptError)), and
mirror that filter for preRequestAssertionResults when computing failed counts
so totals and failed counts remain consistent (refer to totalPreRequestTests,
failedPreRequestTests, preRequestTestResults, and preRequestAssertionResults).

In `@packages/bruno-electron/src/ipc/network/index.js`:
- Around line 446-476: The synthetic error result created in
appendScriptErrorResult should include isScriptError: true so aggregations that
filter by that flag can distinguish script errors from regular test failures;
update the object pushed into results in appendScriptErrorResult (the entry with
status: 'fail', description: descriptionMap[scriptType]..., error: ...) to also
set isScriptError: true, preserving all existing fields and behavior.

…ror flag in test results (usebruno#7029)

* fix: Enhance error handling for script execution by introducing isScriptError flag in test results

Enhance error reporting in script execution by adding isScriptError flag to error responses

fix: Mark pre-request script errors as failures in runner summary
@sanjaikumar-bruno
sanjaikumar-bruno force-pushed the fix/runner-results-enhancement branch from 0459e4d to 798db04 Compare February 4, 2026 09:30
@bijin-bruno
bijin-bruno merged commit 27da99b into usebruno:main Feb 4, 2026
7 of 9 checks passed
@sanjaikumar-bruno
sanjaikumar-bruno deleted the fix/runner-results-enhancement branch February 4, 2026 11:00
@coderabbitai coderabbitai Bot mentioned this pull request Feb 13, 2026
5 tasks
@coderabbitai coderabbitai Bot mentioned this pull request May 20, 2026
6 tasks done
maxenceleblanc pushed a commit to maxenceleblanc/curly_cats2 that referenced this pull request Jul 20, 2026
* Mark test script errors as failed in runner (usebruno#6261)

* Mark test script errors as failed in runner
    and CLI

* Unify handling of post-response and pre-request script errors in both CLI and Electron

* feat: Enhance error handling in script execution by preserving partial results for pre-request and post-response scripts across CLI and Electron. This ensures that tests passing before an error are still reported.

* Preserving stopExecution in test script error handler

---------

Co-authored-by: Pragadesh-45 <[email protected]>

* Enhance error handling for script execution by introducing isScriptError flag in test results (usebruno#7029)

* fix: Enhance error handling for script execution by introducing isScriptError flag in test results

Enhance error reporting in script execution by adding isScriptError flag to error responses

fix: Mark pre-request script errors as failures in runner summary

---------

Co-authored-by: Karan Pradhan <[email protected]>
Co-authored-by: Pragadesh-45 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runner with test marked as Passed whereas there is an error in the test script

3 participants