web/admin: handle non-string values in formatUUID to prevent Event Log crash#20804
Open
tysoncung wants to merge 1 commit intogoauthentik:mainfrom
Open
web/admin: handle non-string values in formatUUID to prevent Event Log crash#20804tysoncung wants to merge 1 commit intogoauthentik:mainfrom
tysoncung wants to merge 1 commit intogoauthentik:mainfrom
Conversation
… 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
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #20803
When navigating to Events → Log, the page crashes with:
Why
The
formatUUIDfunction inweb/src/admin/events/utils.tsassumes its argument is always a string. However,event.context.device.pkfrom the API can be a non-string value (e.g., integer or UUID object), sinceEventContextvalues are dynamically typed (EventContextProperty). WhenformatUUIDreceives a non-string, calling.substring()throws aTypeError, crashing the entire Event Log page.How
Added a type guard at the top of
formatUUIDthat checkstypeof hex !== "string"and coerces toString()if needed, rather than crashing. This is a minimal, defensive fix that keeps the rest of the function logic unchanged.Testing
number,undefined, andnullinputs without throwing