Return 500 errors for missing email templates and AI prompts

Changed configuration error handling to throw InvalidOperationException instead of silently using fallback values. This ensures:

1. Missing email templates (critical config) → 500 error to UI
2. Missing AI prompts (critical config) → 500 error to UI
3. Clear error messages indicating config issue
4. Prompts administrators to check database seeding

Services updated:
- EmailTemplateService.Get() throws for missing template
- CvMatcherService.ScorePairAsync() throws for missing AI prompt

This prevents silent failures with degraded service quality and makes it obvious to users that the system has a configuration problem that needs fixing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 16:58:11 +03:00
parent 64e003a639
commit b114156e9c
2 changed files with 6 additions and 5 deletions
@@ -37,8 +37,9 @@ public sealed class EmailTemplateService : IEmailTemplateService
&& _valueCache.TryGetValue(CacheKey(key, "en"), out var fallback))
return fallback;
_logger.LogWarning("Email template not found: key={Key}, language={Language}", key, language);
return key;
throw new InvalidOperationException(
$"Email template not found: key='{key}', language='{language}'. " +
$"This is a configuration error. Ensure the email.Templates table is properly seeded.");
}
/// <inheritdoc />