Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web: Normalize client-side error handling #13595

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

GirlBossRush
Copy link
Contributor

@GirlBossRush GirlBossRush commented Mar 20, 2025

Details

This PR is a preparation for permissions based UI rendering. The primary change in this PR is the parsing of runtime errors into type-safe interfaces. By default TypeScript will leave Promise .catch's error parameter as any to indicate that the error may arise from unexpected sources, such as network issues, runtime type errors, etc.

This PR seeks to both enforce better typing and provide more accurate runtime information.


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make website)

@GirlBossRush GirlBossRush added enhancement New feature or request javascript Pull requests that update Javascript code labels Mar 20, 2025
@GirlBossRush GirlBossRush self-assigned this Mar 20, 2025
@GirlBossRush GirlBossRush requested a review from a team as a code owner March 20, 2025 04:24
Copy link

netlify bot commented Mar 20, 2025

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit 7a97b21
🔍 Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/67dc70cce8536a000746e778

Copy link

netlify bot commented Mar 20, 2025

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 7a97b21
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/67dc70ccf1a9d20007449ca9
😎 Deploy Preview https://deploy-preview-13595--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.76%. Comparing base (bcdc6fc) to head (7a97b21).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13595      +/-   ##
==========================================
+ Coverage   92.74%   92.76%   +0.01%     
==========================================
  Files         794      794              
  Lines       40502    40502              
==========================================
+ Hits        37565    37570       +5     
+ Misses       2937     2932       -5     
Flag Coverage Δ
e2e 47.98% <ø> (+<0.01%) ⬆️
integration 24.30% <ø> (ø)
unit 90.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented Mar 20, 2025

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-7a97b2176bd7e7098e0f6777d7e7216c4077315d
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-7a97b2176bd7e7098e0f6777d7e7216c4077315d

Afterwards, run the upgrade commands from the latest release notes.

@rissson rissson changed the title Normalize client-side error handling web: Normalize client-side error handling Mar 20, 2025
Comment on lines +11 to +18
export function formatGeoEvent(event: EventWithContext): SlottedTemplateResult {
if (!event.context.geo) return nothing;

const { city, country, continent } = event.context.geo;

const parts = [city, country, continent].filter(Boolean);

return html`${parts.join(", ")}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Included in the PR as prep for a type-safe check on the recent events element.

Comment on lines -79 to +80
<small>${EventGeo(item)}</small>`,
<small>${formatGeoEvent(item)}</small>`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs more love in a future iteration but the idea is something like events would have stronger typing, and that formatGeoEvent would operate like a i18n function.

Comment on lines -84 to +89
renderEmpty(): TemplateResult {
renderEmpty(inner?: SlottedTemplateResult): TemplateResult {
if (this.error) {
return super.renderEmpty(inner);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes issue where errors don't render when the empty state is active. IMO this needs fixing in the base Table class but that refactor will need a PR of its own.

@GirlBossRush GirlBossRush requested a review from a team as a code owner March 20, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant