Skip to content

Commit 233849b

Browse files
committed
fix: throw error in case latest version is not present
1 parent c396fad commit 233849b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Shared/Components/Plugin/types.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export interface PluginTagNamesDTO {
1616
tagNames: string[]
1717
}
1818

19+
/**
20+
* Minimal data of child plugins
21+
*/
1922
interface MinimalPluginVersionDataDTO {
2023
id: number
2124
name: string
@@ -26,7 +29,6 @@ interface MinimalPluginVersionDataDTO {
2629

2730
interface DetailedPluginVersionDTO extends MinimalPluginVersionDataDTO {
2831
tags: string[]
29-
isLatest: boolean
3032
inputVariables: VariableType[]
3133
outputVariables: VariableType[]
3234
/**
@@ -87,7 +89,7 @@ export interface PluginDataStoreType {
8789
pluginVersionStore: Record<number, DetailedPluginVersionType>
8890
}
8991

90-
// TODO: Deprecate this type
92+
// TODO: Check if can deprecate this if have time
9193
export interface PluginDetailType extends DetailedPluginVersionType {}
9294
export type PluginListItemType = Pick<PluginDetailType, 'parentPluginId'>
9395

@@ -178,7 +180,7 @@ export interface PluginListProps
178180
/**
179181
* If true, the response would be appended to the existing data
180182
* if false, the existing data would be replaced with the new data
181-
* default value is false
183+
* @default false
182184
*/
183185
appendResponse?: boolean,
184186
) => void
@@ -195,7 +197,9 @@ export interface PluginCardProps
195197
}
196198

197199
export interface PluginCardSkeletonListProps {
198-
// Default value is 3
200+
/**
201+
* @default 3
202+
*/
199203
count?: number
200204
}
201205

src/Shared/Components/Plugin/utils.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const parsePluginDetailsDTOIntoPluginStore = (pluginData: ParentPluginDTO
3434
const pluginVersions = parseMinimalPluginVersionsDTO(plugin.pluginVersions.minimalPluginVersionData)
3535
const latestPluginVersionIndex = pluginVersions.findIndex((pluginVersion) => pluginVersion.isLatest)
3636

37+
// Adding this check to ensure better debugging in case backend panics
38+
if (latestPluginVersionIndex === -1) {
39+
throw new Error('Latest plugin version not found')
40+
}
41+
3742
parentPluginStore[plugin.id] = {
3843
id: plugin.id,
3944
name: plugin.name || '',

0 commit comments

Comments
 (0)