Skip to content

web/admin: handle non-string values in formatUUID to prevent Event Log crash#20804

Open
tysoncung wants to merge 1 commit intogoauthentik:mainfrom
tysoncung:fix/event-log-format-uuid-type-error
Open

web/admin: handle non-string values in formatUUID to prevent Event Log crash#20804
tysoncung wants to merge 1 commit intogoauthentik:mainfrom
tysoncung:fix/event-log-format-uuid-type-error

Conversation

@tysoncung
Copy link

What

Fixes #20803

When navigating to Events → Log, the page crashes with:

TypeError: s.substring is not a function
    at formatUUID (utils.ts:13)

Why

The formatUUID function in web/src/admin/events/utils.ts assumes its argument is always a string. However, event.context.device.pk from the API can be a non-string value (e.g., integer or UUID object), since EventContext values are dynamically typed (EventContextProperty). When formatUUID receives a non-string, calling .substring() throws a TypeError, crashing the entire Event Log page.

How

Added a type guard at the top of formatUUID that checks typeof hex !== "string" and coerces to String() if needed, rather than crashing. This is a minimal, defensive fix that keeps the rest of the function logic unchanged.

Testing

  • Verified the fix handles number, undefined, and null inputs without throwing
  • Existing string inputs continue to format correctly

… crash

When event context contains a device with a non-string pk value,
formatUUID crashes with TypeError: s.substring is not a function,
preventing the entire Event Log page from loading.

Add a type guard to coerce non-string values to their string
representation instead of crashing.

Fixes goauthentik#20803
@tysoncung tysoncung requested a review from a team as a code owner March 9, 2026 17:09
@netlify
Copy link

netlify bot commented Mar 9, 2026

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit d692cbc
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/69aefee4637ff40008bd376f
😎 Deploy Preview https://deploy-preview-20804--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 project configuration.

@netlify
Copy link

netlify bot commented Mar 9, 2026

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit d692cbc
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/69aefee4ca22ae000803d974
😎 Deploy Preview https://deploy-preview-20804--authentik-docs.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 project configuration.

@BeryJu BeryJu changed the title fix(web): handle non-string values in formatUUID to prevent Event Log crash web/admin: handle non-string values in formatUUID to prevent Event Log crash Mar 9, 2026
@GirlBossRush GirlBossRush self-assigned this Mar 10, 2026
@GirlBossRush GirlBossRush added area:frontend Features or issues related to the browser, TypeScript, Node.js, etc backport/version-2026.2 Add this label to PRs to backport changes to version-2026.2 labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Features or issues related to the browser, TypeScript, Node.js, etc backport/version-2026.2 Add this label to PRs to backport changes to version-2026.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event logs fail to load with TypeError: s.substring is not a function

2 participants