{"record":{"id":"4e7e859e91142936","repo":"srbhr/Resume-Matcher","slug":"unsupported-ui-language-request-ui-language-su","errorCode":null,"errorMessage":"Unsupported UI language: {request.ui_language}. Supported: {SUPPORTED_LANGUAGES}","messagePattern":"Unsupported UI language: (.+?)\\. Supported: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"apps/backend/app/routers/config.py","lineNumber":321,"sourceCode":"\n    return LanguageConfigResponse(\n        ui_language=stored.get(\"ui_language\", legacy_language),\n        content_language=stored.get(\"content_language\", legacy_language),\n        supported_languages=SUPPORTED_LANGUAGES,\n    )\n\n\n@router.put(\"/language\", response_model=LanguageConfigResponse)\nasync def update_language_config(\n    request: LanguageConfigRequest,\n) -> LanguageConfigResponse:\n    \"\"\"Update language configuration.\"\"\"\n    stored = _load_config()\n\n    # Validate and update UI language\n    if request.ui_language is not None:\n        if request.ui_language not in SUPPORTED_LANGUAGES:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Unsupported UI language: {request.ui_language}. Supported: {SUPPORTED_LANGUAGES}\",\n            )\n        stored[\"ui_language\"] = request.ui_language\n\n    # Validate and update content language\n    if request.content_language is not None:\n        if request.content_language not in SUPPORTED_LANGUAGES:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Unsupported content language: {request.content_language}. Supported: {SUPPORTED_LANGUAGES}\",\n            )\n        stored[\"content_language\"] = request.content_language\n\n    # Save config\n    _save_config(stored)\n\n    # Support legacy single 'language' field migration","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/config.py#L303-L339","documentation":"A 400 HTTPException raised by update_language_config when request.ui_language is provided but not a member of SUPPORTED_LANGUAGES. The backend only accepts a fixed whitelist of UI languages and rejects anything else before saving config.","triggerScenarios":"PUT/POST language config with ui_language set to a code not in SUPPORTED_LANGUAGES, e.g. 'en_US' when only 'en' is supported, an empty string, or a regional variant.","commonSituations":"Frontend sends a locale (BCP-47 tag with region/script) that the backend whitelist does not include; language list changed between versions and client ships a now-unsupported code.","solutions":["Send a ui_language value exactly matching one of SUPPORTED_LANGUAGES (check GET language config/options)","Normalize client locales to the backend's canonical codes (e.g. 'pt-BR' -> 'pt')","Omit ui_language from the request if you don't intend to change it"],"exampleFix":"// before\nawait api.updateLanguageConfig({ ui_language: 'en_US' })\n// after\nawait api.updateLanguageConfig({ ui_language: 'en' })","handlingStrategy":"validation","validationCode":"const SUPPORTED = await api.getSupportedLanguages()\nif (uiLang && !SUPPORTED.includes(uiLang)) {\n  uiLang = normalizeLocale(uiLang) // e.g. 'en_US' -> 'en'\n  if (!SUPPORTED.includes(uiLang)) uiLang = SUPPORTED[0]\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.updateLanguageConfig({ ui_language: lang })\n} catch (e) {\n  if (e.response?.status === 400 && String(e.response.data.detail).startsWith('Unsupported UI language')) {\n    showToast(`Language ${lang} is not supported`)\n  } else throw e\n}","preventionTips":["Fetch SUPPORTED_LANGUAGES from the backend and constrain the language picker to it","Normalize BCP-47 locales to the backend's canonical codes before sending","Omit ui_language from the payload when not changing it","Update clients when the backend language list changes"],"tags":["validation","http-400","i18n","language"],"backgroundTag":"unsupported-language-code","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}