Skip to content

feat: render error for invalid categorykey in filter url param (cs filtering) (#901)#902

Merged
NoopDog merged 3 commits into
mainfrom
fran/901-validate-category-keys
May 5, 2026
Merged

feat: render error for invalid categorykey in filter url param (cs filtering) (#901)#902
NoopDog merged 3 commits into
mainfrom
fran/901-validate-category-keys

Conversation

@frano-m
Copy link
Copy Markdown
Contributor

@frano-m frano-m commented Apr 29, 2026

Summary

  • Adds shared useValidateFilterKeys hook that validates filter URL param keys against a set of valid keys, throwing DataExplorerError for the ErrorBoundary
  • Refactors ExploreView's useValidateFilterParam to delegate to the shared hook, adding categoryKey validation against configured categories
  • Adds two-tier validation for DataDictionary: shape-only check in the view (before state sync), key validation in the component (after table creation using the table instance)
  • Moves isColumnFilter type guard to common/filters/adapters/tanstack/typeGuards.ts for reuse across TanStack adapter tables
  • Differentiated error messages: malformed param, invalid shape, unknown key (includes the offending key name)
  • Exports getEntityCategoryGroupConfig for reuse by the ExploreView adapter

Closes #901

Test plan

  • npx tsc --noEmit compiles clean
  • npm test — 414/414 tests pass (27 new tests for validateFilterParam, isColumnFilter, getValidCategoryKeys, getValidColumnIds)
  • Manual: ExploreView with ?filter=[{"categoryKey":"bogus","value":["x"]}] → error page
  • Manual: DataDictionary with ?filter=[{"id":"bogus","value":["x"]}] → error page
  • Manual: valid filters still work normally

🤖 Generated with Claude Code

image image image image image

Copilot AI review requested due to automatic review settings April 29, 2026 09:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + validateFilterParam utilities to validate query param shape and (optionally) keys against an allowed set.
  • Refactors ExploreView filter validation to use the shared hook and validate categoryKey against 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.

Comment thread src/common/filters/hooks/UseValidateFilterKeys/utils.ts
Comment thread src/common/filters/hooks/UseValidateFilterKeys/hook.ts Outdated
Comment thread src/common/filters/hooks/UseValidateFilterKeys/hook.ts Outdated
Comment thread src/views/ExploreView/hooks/UseValidateFilterParam/hook.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useValidateFilterKeys hook + validateFilterParam utility to validate filter query params (shape-only or shape+key set).
  • Refactors ExploreView filter param validation to use the shared hook and adds categoryKey validation 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.

Comment thread src/common/filters/hooks/UseValidateFilterKeys/utils.ts Outdated
@frano-m frano-m marked this pull request as ready for review April 29, 2026 10:21
Copilot AI review requested due to automatic review settings April 29, 2026 10:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + validateFilterParam utilities to validate filter URL params (JSON/shape + optional key-set validation).
  • Refactors ExploreView filter-param validation to use the shared hook and validate categoryKey against 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.

@frano-m frano-m force-pushed the fran/901-validate-category-keys branch from facbcd4 to 8233238 Compare May 1, 2026 00:00
frano-m and others added 3 commits May 5, 2026 00:32
…ltering) (#901)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e-decoding (#901)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NoopDog NoopDog force-pushed the fran/901-validate-category-keys branch from 8233238 to 20180e2 Compare May 5, 2026 04:32
Copilot AI review requested due to automatic review settings May 5, 2026 04:32
@NoopDog NoopDog merged commit db04aaa into main May 5, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@frano-m frano-m deleted the fran/901-validate-category-keys branch May 5, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render error for invalid categoryKey in filter URL param (CS filtering)

3 participants