Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix(common): resolve TypeError when opening request from search results (#5842)

Leonic77e420dc6a3c
diff --git a/packages/hoppscotch-common/src/helpers/teams/TeamsSearch.service.ts b/packages/hoppscotch-common/src/helpers/teams/TeamsSearch.service.ts
index 9acbf0d22..4d75a3955 100644
--- a/packages/hoppscotch-common/src/helpers/teams/TeamsSearch.service.ts
+++ b/packages/hoppscotch-common/src/helpers/teams/TeamsSearch.service.ts
@@ -404,14 +404,14 @@ export class TeamSearchService extends Service {
// has inherited data
if (collection.data) {
const parentInheritedData = JSON.parse(collection.data) as {
- auth: HoppRESTAuth
- headers: HoppRESTHeader[]
- variables: HoppCollectionVariable[]
+ auth?: HoppRESTAuth
+ headers?: HoppRESTHeader[]
+ variables?: HoppCollectionVariable[]
}
const inheritedAuth = parentInheritedData.auth
- if (inheritedAuth.authType !== "inherit") {
+ if (inheritedAuth && inheritedAuth.authType !== "inherit") {
return E.right({
parentID: collectionID,
parentName: collection.title,
@@ -448,9 +448,9 @@ export class TeamSearchService extends Service {
// see if it has headers to inherit, if yes, add it to the existing headers
if (collection.data) {
const parentInheritedData = JSON.parse(collection.data) as {
- auth: HoppRESTAuth
- headers: HoppRESTHeader[]
- variables: HoppCollectionVariable[]
+ auth?: HoppRESTAuth
+ headers?: HoppRESTHeader[]
+ variables?: HoppCollectionVariable[]
}
const inheritedHeaders = parentInheritedData.headers
@@ -494,9 +494,9 @@ export class TeamSearchService extends Service {
if (collection.data) {
const parentData = JSON.parse(collection.data) as {
- auth: HoppRESTAuth
- headers: HoppRESTHeader[]
- variables: HoppCollectionVariable[]
+ auth?: HoppRESTAuth
+ headers?: HoppRESTHeader[]
+ variables?: HoppCollectionVariable[]
}
const variables = parentData.variables
diff --git a/packages/hoppscotch-common/src/services/team-collection.service.ts b/packages/hoppscotch-common/src/services/team-collection.service.ts
index dd47b04dd..9daad0bba 100644
--- a/packages/hoppscotch-common/src/services/team-collection.service.ts
+++ b/packages/hoppscotch-common/src/services/team-collection.service.ts
@@ -1144,9 +1144,9 @@ export class TeamCollectionsService extends Service<void> {
}
const data: {
- auth: HoppRESTAuth
- headers: HoppRESTHeader[]
- variables: HoppCollectionVariable[]
+ auth?: HoppRESTAuth
+ headers?: HoppRESTHeader[]
+ variables?: HoppCollectionVariable[]
} = parentFolder.data
? JSON.parse(parentFolder.data)
: {