{"record":{"id":"8a72014c381e9854","repo":"srbhr/Resume-Matcher","slug":"failed-to-load-language-config-status-res-statu","errorCode":null,"errorMessage":"Failed to load language config (status ${res.status}).","messagePattern":"Failed to load language config \\(status (.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/frontend/lib/api/config.ts","lineNumber":268,"sourceCode":"export type SupportedLanguage = 'en' | 'es' | 'zh' | 'ja' | 'pt' | 'fr' | 'ko';\n\nexport interface LanguageConfig {\n  ui_language: SupportedLanguage;\n  content_language: SupportedLanguage;\n  supported_languages: SupportedLanguage[];\n}\n\nexport interface LanguageConfigUpdate {\n  ui_language?: SupportedLanguage;\n  content_language?: SupportedLanguage;\n}\n\n// Fetch language configuration\nexport async function fetchLanguageConfig(): Promise<LanguageConfig> {\n  const res = await apiFetch('/config/language', { credentials: 'include' });\n\n  if (!res.ok) {\n    throw new Error(`Failed to load language config (status ${res.status}).`);\n  }\n\n  return res.json();\n}\n\n// Update language configuration\nexport async function updateLanguageConfig(update: LanguageConfigUpdate): Promise<LanguageConfig> {\n  const res = await apiFetch('/config/language', {\n    method: 'PUT',\n    headers: { 'Content-Type': 'application/json' },\n    credentials: 'include',\n    body: JSON.stringify(update),\n  });\n\n  if (!res.ok) {\n    const data = await res.json().catch(() => ({}));\n    throw new Error(data.detail || `Failed to update language config (status ${res.status}).`);\n  }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/frontend/lib/api/config.ts#L250-L286","documentation":"fetchLanguageConfig calls GET /config/language with credentials and throws this Error when the response is not ok. Like the other fetch wrappers it drops the response body, so only the status code is available for diagnosis.","triggerScenarios":"GET /config/language returns non-OK: 401 unauthenticated, 404 route absent (older backend), 500 backend language-config store failure.","commonSituations":"Opening the language settings with an expired session; frontend/backend version skew where the language config API was added later; backend storage error on startup.","solutions":["Re-login if the status is 401/403","Confirm the backend version exposes GET /config/language (404)","Inspect backend logs for 500 root causes","Verify the frontend API base URL and proxy configuration"],"exampleFix":"// before\nconst lc = await fetchLanguageConfig();\n// after\nconst lc = await fetchLanguageConfig().catch(() => DEFAULT_LANGUAGE_CONFIG);","handlingStrategy":"fallback","validationCode":"const sessionOk = document.cookie.includes('session');\nif (!sessionOk) await ensureLogin(); // before GET /config/language","typeGuard":"function isLanguageConfigError(e: unknown): e is Error & { status?: number } {\n  const m = e instanceof Error ? e.message.match(/status (\\d{3})/) : null;\n  if (e instanceof Error && m) (e as any).status = Number(m[1]);\n  return e instanceof Error;\n}","tryCatchPattern":"let langConfig: LanguageConfig;\ntry {\n  langConfig = await fetchLanguageConfig();\n} catch {\n  langConfig = DEFAULT_LANGUAGE_CONFIG;\n}","preventionTips":["Keep frontend/backend in version lockstep so the language route exists","Provide DEFAULT_LANGUAGE_CONFIG matching backend defaults","Handle 401 by redirecting to login rather than surfacing a raw error","Smoke-test GET /config/language in deployment checks"],"tags":["http","config","i18n","frontend"],"backgroundTag":"http-error-response","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}