Skip to content

Commit 955ea72

Browse files
committed
fix(cron): make translation check non-fatal during startup
The translation system may not be fully initialized when cron tasks are being registered during startup, even though the translations exist in the embedded binary. Change the fatal error to a warning to allow service startup to complete successfully.
1 parent f89a20b commit 955ea72

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

services/cron/tasks.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,14 @@ func GetTask(name string) *Task {
158158
func RegisterTask(name string, config Config, fun func(context.Context, *user_model.User, Config) error) error {
159159
log.Debug("Registering task: %s", name)
160160

161+
// Check if translation exists, but only if locales are fully initialized
161162
i18nKey := "dashboard." + name
162-
if value := translation.NewLocale("en-US").TrString(i18nKey); value == i18nKey {
163-
return fmt.Errorf("translation is missing for task %q, please add translation for %q", name, i18nKey)
163+
locale := translation.NewLocale("en-US")
164+
if locale != nil {
165+
if value := locale.TrString(i18nKey); value == i18nKey {
166+
log.Warn("translation may be missing for task %q, expected translation key %q", name, i18nKey)
167+
// Don't fail during registration - the translation system may not be fully ready yet
168+
}
164169
}
165170

166171
_, err := setting.GetCronSettings(name, config)

0 commit comments

Comments
 (0)