ory/kratos · error
received unexpected message template type
Error message
received unexpected message template type: %s
What it means
NewEmailTemplateFromMessage switched over the message's template type and fell through every known case into the default branch. The stored TemplateType string does not match any email template the running courier binary knows about, typically because the message was written by a newer/older kratos version than the courier processing it.
Solutions
- Upgrade the kratos and courier components to matching versions so template types align
- Inspect the queued message's template_type value to identify the mismatch
- Drain or delete stale queued messages produced by the incompatible version
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at courier/email_templates.go:118 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07).
Data as JSON: /api/errors/aab127eb3891dbec.
Report an issue: GitHub.
Appendix: source
Thrown at courier/email_templates.go:118
var t email.RegistrationCodeValidModel
if err := json.Unmarshal(msg.TemplateData, &t); err != nil {
return nil, err
}
return email.NewRegistrationCodeValid(d, &t), nil
case template.TypeVerifiableAddressChanged:
var t email.VerifiableAddressChangedModel
if err := json.Unmarshal(msg.TemplateData, &t); err != nil {
return nil, err
}
return email.NewVerifiableAddressChanged(d, &t), nil
case template.TypeAuthenticatorKeyAdded:
var t email.AuthenticatorKeyAddedModel
if err := json.Unmarshal(msg.TemplateData, &t); err != nil {
return nil, err
}
return email.NewAuthenticatorKeyAdded(d, &t), nil
default:
return nil, errors.Errorf("received unexpected message template type: %s", msg.TemplateType)
}
}
View on GitHub (pinned to b86338da04)