srbhr/Resume-Matcher · error · Error
${data.detail || Failed to update language config (status ${
Error message
${data.detail || Failed to update language config (status ${res.status}).} What it means
updateLanguageConfig PUTs the language update to /config/language and throws an Error on non-OK responses, using the backend JSON `detail` field when present (FastAPI error payloads) and otherwise a generic status-message fallback; body parse failures are swallowed with .catch(() => ({})).
Source
Thrown at apps/frontend/lib/api/config.ts:285
if (!res.ok) {
throw new Error(`Failed to load language config (status ${res.status}).`);
}
return res.json();
}
// Update language configuration
export async function updateLanguageConfig(update: LanguageConfigUpdate): Promise<LanguageConfig> {
const res = await apiFetch('/config/language', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify(update),
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to update language config (status ${res.status}).`);
}
return res.json();
}
export interface PromptOption {
id: string;
label: string;
description: string;
}
export interface PromptConfig {
default_prompt_id: string;
prompt_options: PromptOption[];
}
export interface PromptConfigUpdate {
default_prompt_id?: string;View on GitHub (pinned to 116f9cc3b0)
Solutions
- Use the `detail` in the thrown message to fix the submitted language code — it must match the backend's supported-language list
- Re-login if status is 401/403
- Validate the language code against the backend's supported list client-side before submitting
- Check backend logs if the generic fallback message appears (500)
Example fix
// before
await updateLanguageConfig({ contentLanguage: 'jp' }); // 422 unsupported code
// after
await updateLanguageConfig({ contentLanguage: 'ja' }); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = ['en','de','fr','es','ja','zh'];
function validateLanguageUpdate(u: { contentLanguage: string }): string | null {
return SUPPORTED.includes(u.contentLanguage) ? null : `unsupported language: ${u.contentLanguage}`;
} Type guard
function hasDetail(x: unknown): x is { detail: string } {
return typeof x === 'object' && x !== null && 'detail' in x && typeof (x as any).detail === 'string';
} Try / catch
try {
await updateLanguageConfig(update);
} catch (e) {
showToast(e instanceof Error ? e.message : 'Language update failed'); // may carry backend detail
} Prevention
- Derive the language picker options from the backend's supported-language list
- Normalize ISO codes (e.g. 'jp' -> 'ja') before submitting
- Refresh the session before mutations after idle
- Handle the thrown `detail` message in the UI instead of swallowing it
When it happens
Trigger: Saving a content language the backend rejects: 422 validation (unsupported language code), 401 session expired, 500 persistence failure.
Common situations: Submitting a language code not in the backend's supported list (e.g. after a locale rename); session expiring mid-edit; backend DB write failure.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- ${message = data.detail or Failed to update LLM config (stat
- ${data.detail || Failed to update feature config (status ${r
- Failed to load language config (status ${res.status}).
- Failed to load LLM config (status ${res.status}).
- Failed to load feature config (status ${res.status}).
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/f688ba961b19cc1e.
Report an issue: GitHub.