From 93ec1ada9ca7892bd91298adbb512a112fb9ac8b Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Tue, 17 Mar 2026 12:17:39 +0100 Subject: [PATCH] fix: add null guards in hub displayItems filters to prevent TypeError Co-Authored-By: Claude Opus 4.6 --- .../flows/pickers/PickHubApp.svelte | 121 +++++++-------- .../flows/pickers/PickHubFlow.svelte | 125 ++++++++-------- .../flows/pickers/PickHubScript.svelte | 141 +++++++++--------- 3 files changed, 195 insertions(+), 192 deletions(-) diff --git a/frontend/src/lib/components/flows/pickers/PickHubApp.svelte b/frontend/src/lib/components/flows/pickers/PickHubApp.svelte index 6118c5dd9e..2f984bce95 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubApp.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubApp.svelte @@ -47,11 +47,11 @@ let result = filteredItems if (summaryFilter) { const s = summaryFilter.toLowerCase() - result = result.filter((x) => x.summary.toLowerCase().includes(s)) + result = result.filter((x) => (x.summary ?? '').toLowerCase().includes(s)) } if (pathFilter) { const p = pathFilter.toLowerCase() - result = result.filter((x) => x.path.toLowerCase().includes(p)) + result = result.filter((x) => (x.path ?? '').toLowerCase().includes(p)) } return result }) @@ -74,68 +74,69 @@ {#if $disableHubStore} {:else} - x.summary + ' (' + x.apps.join(', ') + ')'} -/> -{#if !hideSearchbar} -
- {@render children?.()} - x.summary + ' (' + x.apps.join(', ') + ')'} /> -
-{/if} - + {#if !hideSearchbar} +
+ {@render children?.()} + +
+ {/if} + -{#if hubNotAvailable} - - Could not connect to the Windmill Hub. If you are in a closed environment, you can disable the Hub in the instance settings. - -{:else if hubApps} - {#if displayItems.length == 0} - - {:else} -
    - {#each displayItems as item (item)} -
  • - -
  • - {/each} -
+
+ {#each item.apps as app} + {app} + {/each} +
+ + + {/each} + + {/if} + {:else} + {#each Array(10).fill(0) as _} + + {/each} {/if} -{:else} - {#each Array(10).fill(0) as _} - - {/each} -{/if} {/if} diff --git a/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte b/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte index dd1415b56a..6e710766bb 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte @@ -47,11 +47,11 @@ let result = filteredItems if (summaryFilter) { const s = summaryFilter.toLowerCase() - result = result.filter((x) => x.summary.toLowerCase().includes(s)) + result = result.filter((x) => (x.summary ?? '').toLowerCase().includes(s)) } if (pathFilter) { const p = pathFilter.toLowerCase() - result = result.filter((x) => x.path.toLowerCase().includes(p)) + result = result.filter((x) => (x.path ?? '').toLowerCase().includes(p)) } return result }) @@ -74,70 +74,71 @@ {#if $disableHubStore} {:else} - x.summary + ' (' + x.apps.join(', ') + ')'} -/> -{#if !hideSearchbar} -
- {@render children?.()} - x.summary + ' (' + x.apps.join(', ') + ')'} /> -
-{/if} - + {#if !hideSearchbar} +
+ {@render children?.()} + +
+ {/if} + -{#if hubNotAvailable} - - Could not connect to the Windmill Hub. If you are in a closed environment, you can disable the Hub in the instance settings. - -{:else if hubFlows} - {#if displayItems.length == 0} - - {:else} -
    - {#each displayItems as item (item)} -
  • - -
  • - {/each} -
- {/if} -{:else} -
+
+ {#each item.apps as app} + {app} + {/each} +
+ + + {/each} + + {/if} + {:else} +
- {#each Array(10).fill(0) as _} - - {/each} -{/if} + {#each Array(10).fill(0) as _} + + {/each} + {/if} {/if} diff --git a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte index e0269258ee..434e85f880 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte @@ -143,11 +143,11 @@ let result = items if (summaryFilter) { const s = summaryFilter.toLowerCase() - result = result.filter((x) => x.summary.toLowerCase().includes(s)) + result = result.filter((x) => (x.summary ?? '').toLowerCase().includes(s)) } if (pathFilter) { const p = pathFilter.toLowerCase() - result = result.filter((x) => x.path.toLowerCase().includes(p)) + result = result.filter((x) => (x.path ?? '').toLowerCase().includes(p)) } return result }) @@ -165,74 +165,75 @@ {#if $disableHubStore} {:else} -{#if !hideSearchbar} -
- {@render children?.()} -
- - {#if loading} - - {/if} -
-
-{/if} - -{#if hubNotAvailable} - - Could not connect to the Windmill Hub. If you are in a closed environment, you can disable the Hub in the instance settings. - -{:else if (items.length > 0 && apps.length > 0) || !loading} - - {#if displayItems.length == 0} - - {:else} -
    - {#each displayItems as item (item.path)} -
  • - -
  • - {/each} -
- {/if} - {#if displayItems.length == 20} -
- There are more items than being displayed. Refine your search. + {#if !hideSearchbar} +
+ {@render children?.()} +
+ + {#if loading} + + {/if} +
{/if} -{:else} - {#each Array(10).fill(0) as _} - - {/each} -{/if} + + {#if hubNotAvailable} + + Could not connect to the Windmill Hub. If you are in a closed environment, you can disable the + Hub in the instance settings. + + {:else if (items.length > 0 && apps.length > 0) || !loading} + + {#if displayItems.length == 0} + + {:else} +
    + {#each displayItems as item (item.path)} +
  • + +
  • + {/each} +
+ {/if} + {#if displayItems.length == 20} +
+ There are more items than being displayed. Refine your search. +
+ {/if} + {:else} + {#each Array(10).fill(0) as _} + + {/each} + {/if} {/if}