Skip to content

feat: Add an accordion to the unknown error page that lets the user see information about the error#4210

Merged
phlipsterit merged 12 commits into
mainfrom
feat/show-detailed-error-info
May 15, 2026
Merged

feat: Add an accordion to the unknown error page that lets the user see information about the error#4210
phlipsterit merged 12 commits into
mainfrom
feat/show-detailed-error-info

Conversation

@phlipsterit
Copy link
Copy Markdown
Contributor

@phlipsterit phlipsterit commented May 15, 2026

Description

On the error page, there were noe information about the error, making it very hard to debug. This PR adds information to make such errors easier to debug. T

Initial view for the user after changes in this PR:
image

After the user have expanded the deails :
image

Details

The information is hidden by default with an Accordion to not overwhelm the user with technical details.
When the information is expanded, we show :

  • Error Name
  • Error message
  • Url in browser (might give us useful information as partyId)
  • Time (lets us easier find related logs)
  • If it was an axios, we show the http status code.

A button to copy the details to the clipboard is also added. This makes it easier for the user to copy all the information we need for debugging and send it to us.

A required error-property has been added to the UnknownError-component. This ensures that we always have some information to show.
The UnknownError-component was used in src/features/instantiate/InstantiationError.tsx, but it seems that Component was never used, so I removed it.

Related Issue(s)

  • closes #18744

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • New Features

    • Added expandable error details panel with copy-to-clipboard for easier reporting.
  • Bug Fixes

    • Error UI now surfaces actual error information across multiple flows.
    • Minor markup adjustment to error content for more appropriate semantics.
  • Localization

    • Added translations for copy action and error-details UI text.
  • Tests

    • Updated tests to cover error details visibility and copy-to-clipboard behavior; test setup adjusted to use real error detection.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

This PR refactors UnknownError to accept and display an Error/AxiosError via a new UnknownErrorDetails component (accordion, location/time, optional response status, stacktrace, copy-to-clipboard). Error objects are propagated from multiple handlers, localization keys added, and tests updated to exercise the details UI.

Changes

Error Detail Display Enhancement

Layer / File(s) Summary
UnknownError component refactoring
src/features/instantiate/containers/UnknownError.tsx, src/features/instantiate/containers/UnknownError.module.css
UnknownError signature changes to accept error: Error | AxiosError prop. Component now renders UnknownErrorDetails and applies errorDetails CSS class for spacing.
UnknownErrorDetails implementation
src/features/instantiate/containers/UnknownErrorDetails.tsx, src/features/instantiate/containers/UnknownErrorDetails.module.css
New component renders error details in an accordion including error name, message, location, timestamp, optional response status, and stack trace. Copy-to-clipboard button serializes error info to JSON, updates UI state on success, and shows checkmark feedback.
Test updates and jest setup
src/features/instantiate/containers/UnknownError.test.tsx, src/App.test.tsx
Tests un-mock axios, import user-event, render UnknownError with an Error instance, click the details button, and assert the error message appears; App test un-mocks axios to use real isAxiosError.
Localization for error details UI
src/language/texts/en.ts, src/language/texts/nb.ts, src/language/texts/nn.ts
Adds general.copy, general.copied, and instantiate.unknown_error_show_details keys across English, Bokmål, and Nynorsk; corrects English instantiate unknown error strings.
Error propagation to UnknownError
src/core/errorHandling/DisplayError.tsx, src/features/instantiate/InstantiationError.tsx, src/features/instantiate/containers/InstantiateContainer.tsx, src/layout/SigningActions/PanelAwaitingCurrentUserSignature.tsx
DisplayError, InstantiationError, InstantiateContainer, and PanelAwaitingCurrentUserSignature now pass error objects to UnknownError instead of rendering it without arguments.
AltinnError container element change
src/components/altinnError.tsx
Content prop container changes from <p> to <section> element with the same CSS classes.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an accordion to the unknown error page that displays error details to users.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description covers all major required sections with clear explanations, screenshots, and comprehensive verification/QA checklists.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/show-detailed-error-info

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/instantiate/containers/UnknownErrorDetails.tsx`:
- Around line 31-45: In handleCopyErrorClicked, awaiting
navigator.clipboard.writeText and handling rejection is required so
setCopied(true) only runs on successful write; update the function to await the
Promise returned by navigator.clipboard.writeText(JSON.stringify(errorInfo,
null, 2)), wrap it in try/catch, call setCopied(true) inside the try block on
success, and in the catch block clear or set an error flag (e.g.,
setCopied(false) or setCopyError) and optionally log the error so
denied/insecure-context failures don’t show a successful copy state.

In `@src/features/instantiate/InstantiationError.tsx`:
- Line 23: The current return in InstantiationError creates a new synthetic
Error and discards the original `error`, losing diagnostics; instead pass the
original `error` through to the UnknownError component (use UnknownError's
`error` prop) so the original Axios/stack details are preserved — if `error` may
not be an Error instance, wrap it in a new Error but retain the original as the
cause or a property (e.g., include `cause` or `originalError`) so full
diagnostics remain available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc2da5e0-4ff1-4f8e-b979-f7c2de4cf3bc

📥 Commits

Reviewing files that changed from the base of the PR and between 354d5fe and b6b1fc5.

📒 Files selected for processing (13)
  • src/components/altinnError.tsx
  • src/core/errorHandling/DisplayError.tsx
  • src/features/instantiate/InstantiationError.tsx
  • src/features/instantiate/containers/InstantiateContainer.tsx
  • src/features/instantiate/containers/UnknownError.module.css
  • src/features/instantiate/containers/UnknownError.test.tsx
  • src/features/instantiate/containers/UnknownError.tsx
  • src/features/instantiate/containers/UnknownErrorDetails.module.css
  • src/features/instantiate/containers/UnknownErrorDetails.tsx
  • src/language/texts/en.ts
  • src/language/texts/nb.ts
  • src/language/texts/nn.ts
  • src/layout/SigningActions/PanelAwaitingCurrentUserSignature.tsx

Comment thread src/features/instantiate/containers/UnknownErrorDetails.tsx Outdated
Comment thread src/features/instantiate/InstantiationError.tsx Outdated
@phlipsterit phlipsterit added kind/product-feature Pull requests containing new features backport This PR should be cherry-picked onto older release branches labels May 15, 2026
@phlipsterit
Copy link
Copy Markdown
Contributor Author

/publish

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.30.0-pr.5147.show-detailed-error-info.8ced8a6c/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.30.0-pr.5147.show-detailed-error-info.8ced8a6c/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@sonarqubecloud
Copy link
Copy Markdown

@phlipsterit phlipsterit merged commit dccae9d into main May 15, 2026
16 checks passed
@phlipsterit phlipsterit deleted the feat/show-detailed-error-info branch May 15, 2026 13:26
@github-actions
Copy link
Copy Markdown
Contributor

Automatic backport successful!

A backport PR has been automatically created for the release/v4.30 release branch.

The release branch release/v4.30 already existed and was updated.

The cherry-pick was clean with no conflicts. Please review the backport PR when it appears.

phlipsterit added a commit that referenced this pull request May 15, 2026
…ee information about the error (#4210)

* Create a unknown error details component

* clean up css

* Add copied feedback

* add translations

* Add error to usages of UnknownError

* Add unit test

* add comment about availability of clipboard

* Add error when using UknownError from InstantiateContainer

* await and try-catch clipboard.writeText

* Delete InstantiationError since its not in use

* Fix tests

* improve test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR should be cherry-picked onto older release branches kind/product-feature Pull requests containing new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it possible to show detailed information about the error when an unknown error occurs in App frontend

2 participants