fix(api): handle null createdAt in AuditedUser to prevent admin 500 - #704
fix(api): handle null createdAt in AuditedUser to prevent admin 500#704blink-claw-bot wants to merge 1 commit into
Conversation
When a MongoDB user document lacks a `createdAt` field, `translateToUser` would pass through `undefined`, causing a GraphQL error since `AuditedUser.createdAt` is declared as `Timestamp!` (non-null). Fall back to Unix epoch (`new Date(0)`) for missing `createdAt` values, signaling "unknown" rather than crashing the admin account details page. Closes blinkbitcoin#703
Why does the admin-panel show "unknown creation date" ? Is that a convention somewhere? |
|
Good question — the admin panel doesn't literally show "unknown creation date" as text. The Unix epoch fallback ( It's not a formal convention in the codebase — it was chosen here as the least-disruptive fix. The alternative would be making |
Summary
AuditedUser.createdAtis declaredTimestamp!(non-null) in the admin GraphQL schema, buttranslateToUserpasses throughundefinedwhen the underlying MongoDB document has nocreatedAtfield. This causes HTTP 500 on the admin account details page.new Date(0)) whencreatedAtis missing/null, signaling "unknown creation date" rather than crashing.translateToUserreturns a valid Date (epoch) for records with missingcreatedAt, and preserves existing values.Test plan
translateToUserwith missingcreatedAtreturnsnew Date(0)translateToUserwith validcreatedAtpreserves the original valuecreatedAtCloses #703