{"record":{"id":"8d140297a39bb8d8","repo":"AdguardTeam/AdGuardHome","slug":"unknown-language-q","errorCode":null,"errorMessage":"unknown language: %q","messagePattern":"unknown language: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/home/i18n.go","lineNumber":60,"sourceCode":"\t\"sv\",\n\t\"th\",\n\t\"tr\",\n\t\"uk\",\n\t\"vi\",\n\t\"zh-cn\",\n\t\"zh-hk\",\n\t\"zh-tw\",\n)\n\n// validateLang returns a standard error about if lang is an unknown language.\n// If allowEmpty is true, the language can also be empty.\nfunc validateLang(lang string, allowEmpty bool) (err error) {\n\tif allowEmpty && lang == \"\" {\n\t\treturn nil\n\t}\n\n\tif !allowedLanguages.Has(lang) {\n\t\treturn fmt.Errorf(\"unknown language: %q\", lang)\n\t}\n\n\treturn nil\n}\n\n// languageJSON is the JSON structure for language requests and responses.\ntype languageJSON struct {\n\tLanguage string `json:\"language\"`\n}\n\n// handleI18nCurrentLanguage is the handler for the GET\n// /control/i18n/current_language HTTP API.\n//\n// TODO(d.kolyshev): Deprecated, remove it later.\nfunc (web *webAPI) handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\tl := web.logger\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/i18n.go#L42-L78","documentation":"validateLang rejects a language string that is not in the allowed set of AdGuard Home UI languages. It is called on install-config checks, apply-config requests, language-change requests, and profile updates.","triggerScenarios":"Sending a PUT to /control/profile/update, /control/i18n/update, or the install-config endpoints with a language field not in the compiled-in allowedLanguages set (e.g. 'jp' instead of 'ja', or a language not enabled in this build).","commonSituations":"Clients (mobile apps, third-party scripts) sending locale codes with region suffixes like 'en-US' or wrong ISO 639 codes; custom builds with a reduced set of translations.","solutions":["Use an exact supported code (e.g. 'en', 'ru', 'zh-cn') — check the UI language dropdown for valid values","Don't send region-qualified locales; strip them before sending","Update to a newer build if the language was added after your binary was compiled"],"exampleFix":"// before\n{\"name\":\"admin\",\"language\":\"en-US\"}\n\n// after\n{\"name\":\"admin\",\"language\":\"en\"}","handlingStrategy":"validation","validationCode":"var allowedLangs = slice.ToSet(locales)\nif !allowedLangs.Has(req.Language) { req.Language = \"en\" }","typeGuard":"func isValidLang(s string) bool { return allowedLanguages.Has(s) }","tryCatchPattern":null,"preventionTips":["Send bare ISO codes matching the UI dropdown values","Default unknown client locales to \"en\" instead of forwarding raw Accept-Language"],"tags":["go","i18n","validation","http-api","config"],"backgroundTag":"enum-value-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}