Skip to content

feat: [CGC-75] Improve the error messages for config error#94

Merged
henrikmv merged 10 commits into
masterfrom
CGC-75
Mar 22, 2026
Merged

feat: [CGC-75] Improve the error messages for config error#94
henrikmv merged 10 commits into
masterfrom
CGC-75

Conversation

@henrikmv

@henrikmv henrikmv commented Mar 21, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown

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 reworks configuration/runtime validation and error rendering for the Capture Growth Chart plugin, aiming to provide clearer configuration-related feedback and reduce silent failures.

Changes:

  • Adds deeper config validation (UID format checks, program-stage mapping validation, option code validation) and a redesigned validation UI with in-app help text.
  • Refactors plugin data fetching (new hooks for program tracked entity attributes, TEI attributes, program stage data elements, option codes) and centralizes loading/error rendering via usePluginErrorHandling.
  • Simplifies/removes several legacy error flows/components (default indicator error, TEI-by-id hook, “missing growth variables” filter/error).

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils/Hooks/Calculations/useAppropriateChartData.ts Removes default-indicator error flagging; selects initial category/dataset from config.
src/utils/DataFetching/Sorting/useMappedTrackedEntity.ts Refactors TEI field mapping to use TEI attributes list and memoization.
src/utils/DataFetching/Sorting/useFilterByMissingData.ts Deletes measurement-based chart filtering logic.
src/utils/DataFetching/Sorting/index.ts Removes export for deleted missing-data filter hook.
src/utils/DataFetching/Hooks/useTrackedEntityInstanceAttributes.ts New hook to fetch TEI attributes via tracker endpoint (Capture-like projection).
src/utils/DataFetching/Hooks/useTeiById.ts Deletes older TEI fetch hook.
src/utils/DataFetching/Hooks/useRuntimeValidation.ts Changes runtime validation to focus on program tracked entity attribute load failures.
src/utils/DataFetching/Hooks/useProgramTrackedEntityAttributes.ts New hook to load program tracked entity attribute IDs for validation.
src/utils/DataFetching/Hooks/useProgramStageMappingValidation.ts New hook validating program→stage mapping by loading program stages.
src/utils/DataFetching/Hooks/useProgramStageDataElements.ts New hook to load program stage data element IDs for validation.
src/utils/DataFetching/Hooks/usePluginErrorHandling.tsx New centralized loading/validation/error view selector for the plugin.
src/utils/DataFetching/Hooks/useInvalidProfileValidation.ts New hook to warn when profile fields needed for charting are missing.
src/utils/DataFetching/Hooks/useGenderAttributeOptionCodes.ts New hook to load gender option set codes for config validation.
src/utils/DataFetching/Hooks/useEvents.ts Changes event query signature/keying; removes TEI scoping.
src/utils/DataFetching/Hooks/useConfigValidation.ts Major upgrade to config validation: UID checks, mapping checks, option code checks, mismatch checks.
src/utils/DataFetching/Hooks/index.ts Updates barrel exports (adds new hooks, removes TEI-by-id export).
src/utils/ChartOptions/PrintDocument.ts Improves PDF naming/title robustness when fields are missing.
src/types/mappedEntityValues.ts Introduces shared MappedEntityValues type + empty constant.
src/components/GrowthChart/GrowthChart.tsx Updates mapped entity type import; removes default-indicator error plumbing.
src/components/GrowthChart/ChartSettingsButton/ChartSettingsButton.tsx Updates mapped entity type import.
src/UI/InvalidProfileValidationWarning/index.ts New export barrel for invalid profile warning UI.
src/UI/InvalidProfileValidationWarning/InvalidProfileValidationWarning.tsx New warning UI component for missing profile fields.
src/UI/GenericLoading/GenericLoading.tsx Simplifies loading skeleton (removes embedded widget wrapper).
src/UI/GenericError/MissingGrowthVariablesError.tsx Removes the “no growth variables” error component.
src/UI/GenericError/GenericError.tsx Adds embedded rendering mode for errors inside the plugin widget.
src/UI/FeedbackComponents/index.ts Removes export for deleted default-indicator error component.
src/UI/FeedbackComponents/TrackedEntityError.tsx Removes tracked entity fetch error component.
src/UI/FeedbackComponents/DefaultIndicatorError.tsx Removes default-indicator error component.
src/UI/FeedbackComponents/CustomReferenceError.tsx Adds embedded mode support.
src/UI/FeedbackComponents/ConfigError.tsx Adds embedded mode support.
src/UI/ConfigValidationError/ConfigValidationError.tsx Replaces alert-stack UI with a richer list + collapsible help section and docs link.
src/Plugin.tsx Refactors plugin orchestration to new hooks, validation, centralized error view, and profile warnings.
i18n/en.pot Updates translation template for new/removed UI strings.
Comments suppressed due to low confidence (1)

src/utils/DataFetching/Hooks/useConfigValidation.ts:345

  • Only checking that settings exists is not enough to prevent mis-typed or unsupported settings from causing incorrect runtime behavior (e.g. customReferences: "false" is truthy, or an invalid defaultIndicator leads to a blank chart). Add validation for boolean settings types and validate settings.defaultIndicator against supported categories (hcfa, lhfa, wfa, wflh) with a clear error message.
                }
            });
        }

        if (!chartConfig.settings) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Plugin.tsx Outdated
Comment thread src/Plugin.tsx
Comment thread src/Plugin.tsx Outdated
Comment thread src/utils/DataFetching/Hooks/usePluginErrorHandling.tsx Outdated
Comment thread src/utils/Hooks/Calculations/useAppropriateChartData.ts Outdated
Comment thread src/utils/DataFetching/Hooks/useEvents.ts

Copilot AI left a comment

Copy link
Copy Markdown

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 34 out of 34 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/DataFetching/Hooks/useEvents.ts
Comment thread src/UI/ConfigValidationError/ConfigValidationError.tsx
Comment thread src/utils/DataFetching/Hooks/useProgramStageDataElements.ts

Copilot AI left a comment

Copy link
Copy Markdown

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 34 out of 34 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/DataFetching/Sorting/useMappedTrackedEntity.ts Outdated
Comment thread src/utils/DataFetching/Hooks/useProgramTrackedEntityAttributes.ts
@henrikmv
henrikmv merged commit 2fa9c04 into master Mar 22, 2026
4 checks passed
@henrikmv
henrikmv deleted the CGC-75 branch March 22, 2026 09:06
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.

2 participants