Fix runtime crashes after struct and DateTime migrations#350
Open
timujinne wants to merge 4 commits intoBeamLabEU:devfrom
Open
Fix runtime crashes after struct and DateTime migrations#350timujinne wants to merge 4 commits intoBeamLabEU:devfrom
timujinne wants to merge 4 commits intoBeamLabEU:devfrom
Conversation
The handle_call for register_groups inserted groups directly into ETS without converting plain maps to Group structs. This could crash sidebar templates that access group fields with dot syntax when parent apps pass plain maps via the public register_groups/1 API.
PR BeamLabEU#347 changed all schema fields from :utc_datetime_usec to :utc_datetime but did not add DateTime.truncate(:second) to all DateTime.utc_now() calls in contexts and schemas. This caused ArgumentError crashes on any DB write operation. Fixed 19 files across settings, billing, shop, emails, referrals, tickets, comments, scheduled jobs, auth, permissions, and roles.
…r id SimplePresence stores user.uuid in user_id field but preload_users_for_sessions passed these UUIDs to get_users_by_ids which queries by integer id column, causing Ecto.Query.CastError. Add get_users_by_uuids/1 and use it for presence user preloading.
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.
Summary
Changes
DateTime truncation (19 files)
PR #347 changed schema fields from
:utc_datetime_usecto:utc_datetimebut did not addDateTime.truncate(:second)toDateTime.utc_now()calls in contexts. This causedArgumentError: :utc_datetime expects microseconds to be emptyon any DB write.Fixed in: settings, billing (invoice/order), shop (products/categories/cart), emails (event/log/templates), referrals, tickets, comments, scheduled jobs, auth (user confirm/anonymize), permissions, role assignments, roles, magic link registration.
Group struct conversion
Registry.handle_call({:register_groups, ...})inserted plain maps directly into ETS without converting to%Group{}structs. Sidebar templates access group fields with dot syntax (.label,.icon,.collapsible) which crashes on plain maps. Added conversion matching the pattern already used inload_from_config_internal.Live sessions UUID fix
SimplePresence.track_userstoresuser.uuidin theuser_idfield, butpreload_users_for_sessionspassed these UUIDs toget_users_by_idswhich queries by integeru.idcolumn, causingEcto.Query.CastError. Addedget_users_by_uuids/1and use it for presence user preloading.Test Plan