[PR #321] [MERGED] Fix selectedRepositories undefined error with generic filter validation #358

Closed
opened 2026-02-26 12:41:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/community-scripts/ProxmoxVE-Local/pull/321
Author: @michelroegl-brunner
Created: 11/14/2025
Status: Merged
Merged: 11/14/2025
Merged by: @MickLesk

Base: mainHead: fix/320


📝 Commits (1)

  • ff26c54 Fix selectedRepositories undefined error with generic filter validation

📊 Changes

4 files changed (+52 additions, -26 deletions)

View changed files

📝 src/app/_components/DownloadedScriptsTab.tsx (+3 -9)
📝 src/app/_components/FilterBar.tsx (+2 -8)
📝 src/app/_components/ScriptsGrid.tsx (+3 -9)
src/app/_components/filterUtils.ts (+44 -0)

📄 Description

Fixes/Prevents issues like #320 in the future.

Problem

Users were experiencing TypeError: can't access property "length", selectedRepositories is undefined when loading saved filters that were created before the selectedRepositories property was added.

Solution

Created a generic filter validation utility that:

  • Provides a single source of truth for default filter values
  • Merges saved filters with defaults, ensuring all properties exist
  • Prevents crashes when loading old saved filters missing new properties
  • Future-proofs against similar issues when new filter properties are added

Changes

  • Created filterUtils.ts with getDefaultFilters() and mergeFiltersWithDefaults() functions
  • Updated ScriptsGrid.tsx, DownloadedScriptsTab.tsx, and FilterBar.tsx to use the utility functions
  • All filter loading now uses mergeFiltersWithDefaults() to ensure complete FilterState objects

Benefits

  • Fixes the immediate crash issue
  • Type-safe: TypeScript ensures all properties are covered
  • Future-proof: New filter properties automatically get defaults
  • No defensive checks needed throughout the codebase
  • Single source of truth for default values

🔄 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/community-scripts/ProxmoxVE-Local/pull/321 **Author:** [@michelroegl-brunner](https://github.com/michelroegl-brunner) **Created:** 11/14/2025 **Status:** ✅ Merged **Merged:** 11/14/2025 **Merged by:** [@MickLesk](https://github.com/MickLesk) **Base:** `main` ← **Head:** `fix/320` --- ### 📝 Commits (1) - [`ff26c54`](https://github.com/community-scripts/ProxmoxVE-Local/commit/ff26c54c4415ec085f278f598dac179b0875c480) Fix selectedRepositories undefined error with generic filter validation ### 📊 Changes **4 files changed** (+52 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src/app/_components/DownloadedScriptsTab.tsx` (+3 -9) 📝 `src/app/_components/FilterBar.tsx` (+2 -8) 📝 `src/app/_components/ScriptsGrid.tsx` (+3 -9) ➕ `src/app/_components/filterUtils.ts` (+44 -0) </details> ### 📄 Description Fixes/Prevents issues like #320 in the future. ## Problem Users were experiencing `TypeError: can't access property "length", selectedRepositories is undefined` when loading saved filters that were created before the `selectedRepositories` property was added. ## Solution Created a generic filter validation utility that: - Provides a single source of truth for default filter values - Merges saved filters with defaults, ensuring all properties exist - Prevents crashes when loading old saved filters missing new properties - Future-proofs against similar issues when new filter properties are added ## Changes - Created `filterUtils.ts` with `getDefaultFilters()` and `mergeFiltersWithDefaults()` functions - Updated `ScriptsGrid.tsx`, `DownloadedScriptsTab.tsx`, and `FilterBar.tsx` to use the utility functions - All filter loading now uses `mergeFiltersWithDefaults()` to ensure complete FilterState objects ## Benefits - ✅ Fixes the immediate crash issue - ✅ Type-safe: TypeScript ensures all properties are covered - ✅ Future-proof: New filter properties automatically get defaults - ✅ No defensive checks needed throughout the codebase - ✅ Single source of truth for default values --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 12:41:06 +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/ProxmoxVE-Local#358
No description provided.