Skip to content

Fix selectedRepositories undefined error with generic filter validation#321

Merged
MickLesk merged 1 commit intomainfrom
fix/320
Nov 14, 2025
Merged

Fix selectedRepositories undefined error with generic filter validation#321
MickLesk merged 1 commit intomainfrom
fix/320

Conversation

@michelroegl-brunner
Copy link
Copy Markdown
Member

@michelroegl-brunner michelroegl-brunner commented Nov 14, 2025

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

- Create filterUtils.ts with getDefaultFilters() and mergeFiltersWithDefaults()
- Update ScriptsGrid, DownloadedScriptsTab, and FilterBar to use utility functions
- Prevents crashes when loading old saved filters missing new properties
- Future-proof: new filter properties automatically get defaults
- Fixes TypeError: can't access property 'length', selectedRepositories is undefined
@michelroegl-brunner michelroegl-brunner requested a review from a team as a code owner November 14, 2025 08:33
@MickLesk MickLesk merged commit f558aa4 into main Nov 14, 2025
4 checks passed
@MickLesk MickLesk deleted the fix/320 branch April 1, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants