feat: render error for invalid categorykey in filter url param (cs filtering) (#901)#902
Conversation
There was a problem hiding this comment.
Pull request overview
Adds shared, reusable validation for filter-style URL params so client-side filtering surfaces invalid keys (via DataExplorerError + ErrorBoundary) instead of silently ignoring them, covering both ExploreView category filters and DataDictionary column filters.
Changes:
- Introduces
useValidateFilterKeys+validateFilterParamutilities to validate query param shape and (optionally) keys against an allowed set. - Refactors ExploreView filter validation to use the shared hook and validate
categoryKeyagainst configured categories. - Adds DataDictionary URL filter validation in two phases (shape-only in the view, key validation against TanStack column IDs in the component) and factors out TanStack
isColumnFilter.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/validateFilterKeys.test.ts | Adds unit tests for validateFilterParam, isColumnFilter, and valid-key extractors for categories/columns. |
| src/common/filters/hooks/UseValidateFilterKeys/utils.ts | Implements core validation logic for URL filter params (decode/parse/shape/key checks). |
| src/common/filters/hooks/UseValidateFilterKeys/hook.ts | Adds shared hook that reads router query param and throws validation errors during render. |
| src/common/filters/adapters/tanstack/typeGuards.ts | Adds reusable TanStack ColumnFilter shape guard. |
| src/views/ExploreView/hooks/UseValidateFilterParam/hook.ts | Replaces bespoke ExploreView validation with shared useValidateFilterKeys + category-key validation. |
| src/views/ExploreView/hooks/UseValidateFilterParam/utils.ts | Adds helpers to extract category keys and compute valid category keys from config. |
| src/providers/exploreState/initializer/utils.ts | Exports getEntityCategoryGroupConfig for reuse in validation utilities. |
| src/views/DataDictionaryView/dataDictionaryView.tsx | Adds early, shape-only URL validation before state sync dispatch. |
| src/components/DataDictionary/dataDictionary.tsx | Validates column filter keys against TanStack table column IDs after table creation. |
| src/components/DataDictionary/utils.ts | Adds helpers to extract column IDs and compute valid IDs from a table instance. |
| src/common/filters/typeGuards.ts | Minor type-only import cleanup. |
There was a problem hiding this comment.
Pull request overview
This PR improves client-side filtering UX by validating filter URL parameter keys (and entry shapes) early and throwing DataExplorerError during render so the app’s ErrorBoundary can display a clear error page instead of silently ignoring invalid filters.
Changes:
- Introduces a shared
useValidateFilterKeyshook +validateFilterParamutility to validate filter query params (shape-only or shape+key set). - Refactors ExploreView filter param validation to use the shared hook and adds
categoryKeyvalidation against configured category keys. - Adds DataDictionary filter validation in two phases (shape validation before state sync; key validation after table creation), plus utilities/type guards and corresponding tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/validateFilterKeys.test.ts | Adds unit tests for validateFilterParam, isColumnFilter, and valid-key extraction helpers. |
| src/common/filters/adapters/tanstack/typeGuards.ts | Adds reusable TanStack ColumnFilter shape guard (isColumnFilter). |
| src/common/filters/hooks/UseValidateFilterKeys/hook.ts | Adds shared hook that reads a query param and throws on invalid shape/keys. |
| src/common/filters/hooks/UseValidateFilterKeys/utils.ts | Adds parsing/validation utility that differentiates malformed JSON/shape/unknown key errors. |
| src/common/filters/typeGuards.ts | Minor type-only import adjustment. |
| src/components/DataDictionary/dataDictionary.tsx | Validates DataDictionary column filter keys against the table’s column IDs after table creation. |
| src/components/DataDictionary/utils.ts | Adds helpers to extract column IDs and build the valid column ID set from a table instance. |
| src/providers/exploreState/initializer/utils.ts | Exports getEntityCategoryGroupConfig for reuse by view-layer validation. |
| src/views/DataDictionaryView/dataDictionaryView.tsx | Adds pre-state-sync shape-only validation for column filter URL params. |
| src/views/ExploreView/hooks/UseValidateFilterParam/hook.ts | Refactors ExploreView to use shared validation hook and validate categoryKey against config. |
| src/views/ExploreView/hooks/UseValidateFilterParam/utils.ts | Adds helpers to extract categoryKey and build the valid category key set from config. |
There was a problem hiding this comment.
Pull request overview
Adds shared URL filter-key validation to ensure invalid filter keys (e.g., unknown categoryKey / column filter id) surface as render-time DataExplorerErrors for the app ErrorBoundary, instead of being silently ignored in client-side filtering flows.
Changes:
- Introduces shared
useValidateFilterKeys+validateFilterParamutilities to validate filter URL params (JSON/shape + optional key-set validation). - Refactors ExploreView filter-param validation to use the shared hook and validate
categoryKeyagainst configured category keys. - Adds DataDictionary validation in two stages: early shape validation in the view, then key validation in the component once the TanStack table instance exists (column IDs available).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/validateFilterKeys.test.ts | Adds unit coverage for URL param validation, TanStack isColumnFilter, and valid-key extraction helpers. |
| src/common/filters/hooks/UseValidateFilterKeys/hook.ts | New shared hook that reads router query params and throws DataExplorerError on invalid shape/keys. |
| src/common/filters/hooks/UseValidateFilterKeys/utils.ts | Implements parsing + validation (malformed param / invalid shape / unknown key) with resilient decoding behavior. |
| src/views/ExploreView/hooks/UseValidateFilterParam/hook.ts | Replaces bespoke validation with shared hook; adds category-key validation using config-derived keys. |
| src/views/ExploreView/hooks/UseValidateFilterParam/utils.ts | Adds helpers to extract categoryKey and compute the valid category key set from config. |
| src/providers/exploreState/initializer/utils.ts | Exports getEntityCategoryGroupConfig for reuse when deriving valid category keys. |
| src/common/filters/adapters/tanstack/typeGuards.ts | Adds reusable TanStack isColumnFilter type guard. |
| src/views/DataDictionaryView/dataDictionaryView.tsx | Adds early (pre-state-sync) shape-only validation for column filter URL params. |
| src/components/DataDictionary/dataDictionary.tsx | Adds post-table-creation key validation against the table’s column IDs. |
| src/components/DataDictionary/utils.ts | Adds helpers to extract column IDs and compute the set of valid column IDs from a table instance. |
| src/common/filters/typeGuards.ts | Minor improvement: switches to a type-only import for SelectedFilter. |
facbcd4 to
8233238
Compare
8233238 to
20180e2
Compare
Summary
useValidateFilterKeyshook that validates filter URL param keys against a set of valid keys, throwingDataExplorerErrorfor the ErrorBoundaryuseValidateFilterParamto delegate to the shared hook, adding categoryKey validation against configured categoriesisColumnFiltertype guard tocommon/filters/adapters/tanstack/typeGuards.tsfor reuse across TanStack adapter tablesgetEntityCategoryGroupConfigfor reuse by the ExploreView adapterCloses #901
Test plan
npx tsc --noEmitcompiles cleannpm test— 414/414 tests pass (27 new tests forvalidateFilterParam,isColumnFilter,getValidCategoryKeys,getValidColumnIds)?filter=[{"categoryKey":"bogus","value":["x"]}]→ error page?filter=[{"id":"bogus","value":["x"]}]→ error page🤖 Generated with Claude Code