Skip to content

feat(apps): improve ErrorMessage type safety#1524

Merged
taymoor89 merged 2 commits intomainfrom
1431-improve-error-message-type
Mar 12, 2026
Merged

feat(apps): improve ErrorMessage type safety#1524
taymoor89 merged 2 commits intomainfrom
1431-improve-error-message-type

Conversation

@taymoor89
Copy link
Contributor

@taymoor89 taymoor89 commented Mar 11, 2026

Summary

Improve ErrorMessage component to accept unknown error types, eliminating unsafe type casting.

Changes Made

  • Change error prop type from Error to unknown
  • Remove unsafe type casting at 4 places.
  • Add proper type guards for Error, string, and unknown types
  • Simplify string error handling

Related Issues

Testing Instructions

  1. pnpm i
  2. pnpm test ErrorMessage
  3. pnpm typecheck

Checklist

  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have made corresponding changes to the documentation (if applicable).
  • My changes generate no new warnings or errors.
  • I have created a changeset for my changes.

@taymoor89 taymoor89 requested a review from a team as a code owner March 11, 2026 13:49
@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 0a98037

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudoperators/juno-app-greenhouse Patch
@cloudoperators/juno-app-heureka Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@taymoor89 taymoor89 force-pushed the 1431-improve-error-message-type branch 3 times, most recently from 64443c3 to 13b5c6f Compare March 11, 2026 13:57
@taymoor89 taymoor89 force-pushed the 1431-improve-error-message-type branch from 13b5c6f to 0a98037 Compare March 11, 2026 14:00
@taymoor89 taymoor89 self-assigned this Mar 11, 2026
@taymoor89 taymoor89 added the greenhouse-pr-preview Builds a PR preview for greenhouse shell app and plugins. label Mar 11, 2026
@ArtieReus ArtieReus requested a review from Copilot March 11, 2026 14:23
Copy link

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

Updates the ErrorMessage component (in both Heureka and Greenhouse apps) to accept unknown errors and safely derive a displayable name/message without as Error casts, aligning with react-error-boundary’s unknown-typed errors.

Changes:

  • Widen ErrorMessage’s error prop from Error to unknown and add type-guarded formatting (Error, string, fallback).
  • Remove unsafe casts at call sites and pass through unknown errors directly.
  • Add unit tests covering string and non-Error unknown error inputs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/heureka/src/components/common/getErrorDataRow.tsx Removes as Error cast; passes unknown error into ErrorMessage.
apps/heureka/src/components/common/Filters/index.tsx Removes as Error cast when forwarding react-error-boundary error.
apps/heureka/src/components/common/Filters/PlaceHolderFilterSelect.tsx Widens error prop to unknown and changes how errortext is derived.
apps/heureka/src/components/common/ErrorBoundary/ErrorMessage.tsx Adds unknown-safe error normalization and updates rendering.
apps/heureka/src/components/common/ErrorBoundary/ErrorMessage.test.tsx Adds tests for string and unknown-object errors.
apps/greenhouse/src/components/admin/common/getErrorDataRow.tsx Removes as Error cast; passes unknown error into ErrorMessage.
apps/greenhouse/src/components/admin/common/YamlViewer.tsx Passes string error directly into ErrorMessage instead of wrapping in Error.
apps/greenhouse/src/components/admin/common/ErrorBoundary/ErrorMessage.tsx Adds unknown-safe error normalization and updates rendering.
apps/greenhouse/src/components/admin/common/ErrorBoundary/ErrorMessage.test.tsx Adds tests for string and unknown-object errors.
.changeset/improve-error-message-type-safety.md Records patch release for both apps.

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

@taymoor89 taymoor89 merged commit 4bbfb0e into main Mar 12, 2026
19 checks passed
@taymoor89 taymoor89 deleted the 1431-improve-error-message-type branch March 12, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

greenhouse-pr-preview Builds a PR preview for greenhouse shell app and plugins.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task](juno): Improve ErrorBoundary types

5 participants