firebase / firebase/firebase-admin-go
MFA UpdateUser fails with "Illegal trailing data" when EnrollmentTimestamp is set
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 274
- Avg merge
- 10h 39m
- Merged PRs (30d)
- 2
Description
### Environment
- firebase-admin-go: v4.20.0
### Problem
Calling `UpdateUser` with an MFA factor whose `EnrollmentTimestamp` is non-zero fails with:
```
{
"error": {
"code": 400,
"message": "Invalid value at 'mfa.enrollments[0].enrolled_at' (type.googleapis.com/google.protobuf.Timestamp), Field 'enrolledAt', Invalid time format: Illegal trailing data in input string",
"errors": [
{
"message": "Invalid value at 'mfa.enrollments[0].enrolled_at' (type.googleapis.com/google.protobuf.Timestamp), Field 'enrolledAt', Invalid time format: Illegal trailing data in input string",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "mfa.enrollments[0].enrolled_at",
"description": "Invalid value at 'mfa.enrollments[0].enrolled_at' (type.googleapis.com/google.protobuf.Timestamp), Field 'enrolledAt', Invalid time format: Illegal trailing data in input string"
}
]
}
]
}
}
```
### Reproduction
```go
user := (&auth.UserToUpdate{}).MFASettings(auth.MultiFactorSettings{
EnrolledFactors: []*auth.MultiFactorInfo{
{
UID: "someuid",
DisplayName: "My phone",
FactorID: "phone",
EnrollmentTimestamp: time.Now().Unix() * 1000,
Phone: &auth.PhoneMultiFactorInfo{PhoneNumber: "+11234567890"},
},
},
})
_, err := client.UpdateUser(ctx, "someuid", user)
// err: "Illegal trailing data in input string"
Setting EnrollmentTimestamp to 0 avoids the error.
```
Contributor guide
Research direction
Start at auth.UserToUpdate.MFASettings and the client.UpdateUser entry point, then trace how MultiFactorInfo.EnrollmentTimestamp is serialized for the MFA enrollment request. Reproduce the issue with a non-zero timestamp and verify that UpdateUser succeeds without the “Illegal trailing data” error while the timestamp is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100