[PR #5814] [MERGED] fix(common): handle null request ref in InspectionService for test-runner tabs #5362

Closed
opened 2026-03-17 02:49:04 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5814
Author: @Leon-Luu
Created: 1/29/2026
Status: Merged
Merged: 1/29/2026
Merged by: @jamesgeorge007

Base: mainHead: fix/issue_5813_pre_hook_error


📝 Commits (3)

  • aab2d61 fix: handle null request in inspection service for test-runner tabs
  • 3969d60 fix: copilot suggestion with debouncedReq as
  • ce4c587 refactor: simplify null guard and type assertion

📊 Changes

1 file changed (+11 additions, -4 deletions)

View changed files

📝 packages/hoppscotch-common/src/services/inspection/index.ts (+11 -4)

📄 Description

Add a null guard before calling getInspections() to:

  1. Skip inspection when request is null
  2. Use type assertion to satisfy TypeScript after the null check
const inspectorRefs = computed(() => {
  // Skip inspection if request is null (e.g., test-runner tab)
  const req = debouncedReq.value
  if (req === null) return []

  return Array.from(this.inspectors.values()).map((x) =>
    x.getInspections(debouncedReq as any, debouncedRes)
  )
})

This null value propagates to debouncedReq, which is then passed to getInspections(), causing a type mismatch.

Closes #
https://github.com/hoppscotch/hoppscotch/issues/5813

What's changed

Notes to reviewers


Summary by cubic

Skip inspection when the request is null to prevent pre-hook errors in test‑runner tabs. Adds a null guard in InspectionService and a type assertion to satisfy TypeScript, avoiding getInspections() calls with a null request.

Written for commit ce4c587b70. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5814 **Author:** [@Leon-Luu](https://github.com/Leon-Luu) **Created:** 1/29/2026 **Status:** ✅ Merged **Merged:** 1/29/2026 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `main` ← **Head:** `fix/issue_5813_pre_hook_error` --- ### 📝 Commits (3) - [`aab2d61`](https://github.com/hoppscotch/hoppscotch/commit/aab2d614f9a68371132b9a434c176f3f04eabf49) fix: handle null request in inspection service for test-runner tabs - [`3969d60`](https://github.com/hoppscotch/hoppscotch/commit/3969d60d5ef63dcdfa356e405c85f5cfeeddb3d1) fix: copilot suggestion with debouncedReq as - [`ce4c587`](https://github.com/hoppscotch/hoppscotch/commit/ce4c587b7015a3dab0727eadec2275d7d38b0c02) refactor: simplify null guard and type assertion ### 📊 Changes **1 file changed** (+11 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/services/inspection/index.ts` (+11 -4) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> Add a null guard before calling getInspections() to: 1. Skip inspection when request is null 2. Use type assertion to satisfy TypeScript after the null check ``` const inspectorRefs = computed(() => { // Skip inspection if request is null (e.g., test-runner tab) const req = debouncedReq.value if (req === null) return [] return Array.from(this.inspectors.values()).map((x) => x.getInspections(debouncedReq as any, debouncedRes) ) }) ``` This null value propagates to debouncedReq, which is then passed to getInspections(), causing a type mismatch. <!-- If this pull request closes an issue, please mention the issue number below --> Closes # <!-- Issue # here --> https://github.com/hoppscotch/hoppscotch/issues/5813 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Skip inspection when the request is null to prevent pre-hook errors in test‑runner tabs. Adds a null guard in InspectionService and a type assertion to satisfy TypeScript, avoiding getInspections() calls with a null request. <sup>Written for commit ce4c587b7015a3dab0727eadec2275d7d38b0c02. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:49:04 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5362
No description provided.