Repository navigation
Fix MFA enrolledAt being sent as a malformed timestamp - #792
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
UpdateUser() with a non-zero EnrollmentTimestamp serialized "53140-03-29T09:33:20+08:00Z" and the Auth backend rejected the whole request with "Invalid time format: Illegal trailing data in input string". The layout had a literal Z after the Z07:00 token, and the field is in milliseconds but was handed to time.Unix as seconds.
The case built both sides with time.Now(), so it never actually pinned the serialized enrolledAt and only matched when the machine timezone happened to line up. Use a fixed millisecond value and expect the exact RFC3339 string the backend now receives.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the multi-factor authentication enrollment timestamp conversion to correctly handle milliseconds since epoch using time.UnixMilli and formats the output in UTC using time.RFC3339. Additionally, the corresponding test cases in auth/user_mgt_test.go have been updated to use static timestamps instead of dynamic current times, ensuring deterministic test runs. There are no review comments to address.
rootkiller6788
marked this pull request as ready for review
October 5, 2026 06:09
This branch has not been deployed
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.
Fixes #764.
UpdateUser() with a non-zero EnrollmentTimestamp sent a broken enrolledAt and the Auth backend threw out the whole request with "Invalid time format: Illegal trailing data in input string". Two things were wrong in convertMultiFactorInfoToServerFormat:
time.UnixMilli(...).UTC().Format(time.RFC3339) fixes both, and GetUser -> UpdateUser round-trips cleanly now.
I also pinned the MFA case in updateUserCases to a fixed timestamp instead of time.Now() on both sides — it never actually asserted the serialized value and only passed when the machine timezone happened to line up.
go test ./auth/ ./messaging/ passes. Reverting just user_mgt.go against the new test makes TestUpdateUser fail with the old malformed string, so the case really does cover this path.