{"record":{"id":"842f42d806753c0e","repo":"NickeManarin/ScreenToGif","slug":"can-t-get-language-codes-path-to-language-codes-i","errorCode":null,"errorMessage":"Can't get language codes. Path to language codes is null","messagePattern":"Can't get language codes\\. Path to language codes is null","errorType":"exception","errorClass":"WebException","httpStatus":null,"severity":"error","filePath":"Other/Translator/TranslatorWindow.xaml.cs","lineNumber":699,"sourceCode":"                \"en-NL;en-NR;en-NU;en-NZ;en-PG;en-PH;en-PK;en-PN;en-PW;en-RW;en-SB;en-SC;en-SD;en-SE;en-SG;en-SH;en-SI;en-SL;en-SS;en-SX;en-SZ;en-TK;en-TO;en-TT;en-TV;\" +\n                \"en-TZ;en-UG;en-VC;en-VU;en-WS;en-ZA;en-ZM;en-ZW;eo;es;es-419;es-AR;es-BO;es-BR;es-BZ;es-CL;es-CO;es-CR;es-CU;es-DO;es-EC;es-GQ;es-GT;es-HN;es-MX;es-NI;\" +\n                \"es-PA;es-PE;es-PH;es-PR;es-PY;es-SV;es-US;es-UY;es-VE;et;eu;ewo;fa;ff;ff-Latn-GH;ff-Latn-GM;ff-Latn-GN;ff-Latn-LR;ff-Latn-MR;ff-Latn-NG;ff-Latn-SL;fi;fil;\" +\n                \"fo;fo-DK;fr;fr-BE;fr-BI;fr-CA;fr-CD;fr-CH;fr-CI;fr-CM;fr-DJ;fr-DZ;fr-GF;fr-GN;fr-HT;fr-KM;fr-LU;fr-MA;fr-MG;fr-ML;fr-MR;fr-MU;fr-RE;fr-RW;fr-SC;fr-SN;fr-SY;\" +\n                \"fr-TD;fr-TN;fr-VU;fur;fy;ga;gd;gl;gsw;gu;guz;gv;ha;haw;he;hi;hr;hr-BA;hsb;hu;hy;ia;id;ig;ii;is;it;it-CH;ja;jgo;jmc;jv;ka;kab;kam;kde;kea;khq;ki;kk;kkj;kl;kln;\" +\n                \"km;kn;ko;ko-KP;kok;ks;ksb;ksf;ksh;ku;kw;ky;lag;lb;lg;lkt;ln;ln-AO;lo;lrc;lrc-IQ;lt;lu;luo;luy;lv;mas;mas-TZ;mer;mfe;mg;mgh;mgo;mi;mk;ml;mn;mni;mr;ms;ms-BN;ms-SG;\" +\n                \"mt;mua;my;mzn;naq;nb;nd;nds;nds-NL;ne;ne-IN;nl;nl-AW;nl-BE;nl-BQ;nl-CW;nl-SR;nl-SX;nmg;nn;nnh;nus;nyn;om;om-KE;or;os;os-RU;pa;pa-Arab;pl;prg;ps;ps-PK;pt;pt-AO;\" +\n                \"pt-CV;pt-GW;pt-LU;pt-MO;pt-MZ;pt-PT;pt-ST;pt-TL;rm;rn;ro;ro-MD;rof;ru;ru-BY;ru-KG;ru-KZ;ru-MD;ru-UA;rw;rwk;sah;saq;sbp;sd;sd-Deva;se;se-FI;se-SE;seh;ses;sg;shi;\" +\n                \"shi-Latn;si;sk;sl;smn;sn;so;so-DJ;so-ET;so-KE;sq;sq-MK;sq-XK;sr;sr-Cyrl-BA;sr-Cyrl-ME;sr-Cyrl-XK;sr-Latn;sr-Latn-BA;sr-Latn-ME;sr-Latn-XK;sv;sv-FI;sw;sw-CD;sw-KE;\" +\n                \"sw-UG;ta;ta-LK;ta-MY;ta-SG;te;teo;teo-KE;tg;th;ti;ti-ER;tk;to;tr;tr-CY;tt;twq;tzm;ug;uk;ur;ur-IN;uz;uz-Arab;uz-Cyrl;vai;vai-Latn;vi;vo;vun;wae;wo;xh;xog;yav;yi;yo;\" +\n                \"yo-BJ;zgh;zh;zh-Hans-HK;zh-Hans-MO;zh-Hant;zu\").Split(';').ToList();\n    }\n\n    private async Task<IEnumerable<string>> GetLanguageCodesAsync()\n    {\n        var path = await GetLanguageCodesPathAsync();\n\n        if (string.IsNullOrEmpty(path))\n            throw new WebException(\"Can't get language codes. Path to language codes is null\");\n\n        var request = (HttpWebRequest)WebRequest.Create(path);\n        request.UserAgent = \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393\";\n\n        var response = (HttpWebResponse)await request.GetResponseAsync();\n\n        using (var resultStream = response.GetResponseStream())\n        {\n            if (resultStream == null)\n                throw new WebException(\"Empty response from server when getting language codes\");\n\n            using (var reader = new StreamReader(resultStream))\n            {\n                var result = await reader.ReadToEndAsync();\n\n                var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(result),\n                    new System.Xml.XmlDictionaryReaderQuotas());\n","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/Other/Translator/TranslatorWindow.xaml.cs#L681-L717","documentation":"Thrown by GetLanguageCodesAsync when GetLanguageCodesPathAsync returns null or empty. GetLanguageCodesPathAsync fetches datahub.io/core/language-codes/datapackage.json and extracts the 'path' of the 'ietf-language-tags_json' resource via XPath. If the JSON structure changed or the request failed internally, the path comes back empty.","triggerScenarios":"GetLanguageCodesPathAsync returns null/empty because: datahub.io is unreachable or returns a non-JSON error page, the 'resources' array or the 'ietf-language-tags_json' entry no longer exists in the datapackage.json, or the XPath query 'path' element is missing.","commonSituations":"Datahub.io API endpoint changed or was deprecated. Network/proxy blocks access to datahub.io. The datapackage.json schema was updated and the resource name 'ietf-language-tags_json' was renamed.","solutions":["Manually browse to https://datahub.io/core/language-codes/datapackage.json and verify the 'resources' array still contains an entry with name 'ietf-language-tags_json' and a 'path' field.","Check network connectivity and proxy settings for datahub.io.","If datahub.io restructured, update the XPath filter in GetLanguageCodesPathAsync to match the new resource name.","Cache the language codes list locally as a fallback when the remote service is unavailable."],"exampleFix":"// before\nvar path = await GetLanguageCodesPathAsync();\nif (string.IsNullOrEmpty(path))\n    throw new WebException(\"Can't get language codes. Path to language codes is null\");\n\n// after: fall back to the hardcoded list rather than throwing\nvar path = await GetLanguageCodesPathAsync();\nif (string.IsNullOrEmpty(path))\n    return GetCachedLanguageCodes(); // returns the built-in hardcoded list","handlingStrategy":"fallback","validationCode":"var path = await GetLanguageCodesPathAsync();\n// Instead of throwing, check and fall back to the hardcoded list\nif (string.IsNullOrEmpty(path))\n    return GetCachedLanguageCodesFromHardcodedList();","typeGuard":null,"tryCatchPattern":"try\n{\n    return await GetLanguageCodesAsync();\n}\ncatch (WebException)\n{\n    return GetCachedLanguageCodesFromHardcodedList(); // built-in list at top of class\n}","preventionTips":["Cache the language codes path after the first successful fetch so subsequent calls don't depend on datahub.io.","Maintain the hardcoded language code list as the authoritative source and use the remote fetch as a refresh only.","Monitor datahub.io availability and switch to a mirror if the primary endpoint goes down."],"tags":["network","datahub","localization","translator","external-dependency"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}