{"record":{"id":"ff5f2258c4a15b73","repo":"searxng/searxng","slug":"invalid-setting-year-from-zlib-year-from","errorCode":null,"errorMessage":"invalid setting year_from: {zlib_year_from}","messagePattern":"invalid setting year_from: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"searx/engines/zlibrary.py","lineNumber":92,"sourceCode":"\nzlib_ext: str = \"\"\n\"\"\"Filter z-library's results by a file ending. Common filters for example are\n``PDF`` and ``EPUB``.\n\"\"\"\n\ni18n_language = gettext(\"Language\")\ni18n_book_rating = gettext(\"Book rating\")\ni18n_file_quality = gettext(\"File quality\")\n\n\ndef setup(engine_settings: dict[str, t.Any]) -> bool:  # pylint: disable=unused-argument\n    \"\"\"Check of engine's settings.\"\"\"\n    traits: EngineTraits = EngineTraits(**ENGINE_TRAITS[\"z-library\"])\n\n    if zlib_ext and zlib_ext not in traits.custom[\"ext\"]:\n        raise ValueError(f\"invalid setting ext: {zlib_ext}\")\n    if zlib_year_from and zlib_year_from not in traits.custom[\"year_from\"]:\n        raise ValueError(f\"invalid setting year_from: {zlib_year_from}\")\n    if zlib_year_to and zlib_year_to not in traits.custom[\"year_to\"]:\n        raise ValueError(f\"invalid setting year_to: {zlib_year_to}\")\n    return True\n\n\ndef request(query: str, params: \"OnlineParams\") -> None:\n    lang: str | None = traits.get_language(params[\"searxng_locale\"], traits.all_locale)\n    search_url: str = (\n        base_url\n        + \"/s/{search_query}/?page={pageno}\"\n        + \"&yearFrom={zlib_year_from}\"\n        + \"&yearTo={zlib_year_to}\"\n        + \"&languages[]={lang}\"\n        + \"&extensions[]={zlib_ext}\"\n    )\n    params[\"url\"] = search_url.format(\n        search_query=quote(query),\n        pageno=params[\"pageno\"],","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/searxng/searxng/blob/9fea41204fdfa7a5cfa15b0ebd12904c520478ce/searx/engines/zlibrary.py#L74-L110","documentation":"setup() validates `zlib_year_from` against the allowed year_from values in ENGINE_TRAITS['z-library'].custom['year_from']; a value outside that list raises ValueError.","triggerScenarios":"Configuring zlib_year_from in settings.yml with a year not in the supported list (e.g. 1800 or a future year).","commonSituations":"User sets an arbitrary year range without knowing the supported set.","solutions":["Set zlib_year_from to a value from ENGINE_TRAITS['z-library'].custom['year_from'] in searx/engines/zlibrary.py","Omit the setting to use the default","Update SearXNG if the supported range changed"],"exampleFix":"# before\n  zlib_year_from: 1500\n# after\n  zlib_year_from: 1800","handlingStrategy":"validation","validationCode":"from searx.engines.zlibrary import ENGINE_TRAITS\nassert zlib_year_from in ENGINE_TRAITS['z-library']['custom']['year_from']","typeGuard":null,"tryCatchPattern":"try:\n    setup(engine_settings)\nexcept ValueError as e:\n    logger.error('bad year_from: %s', e)","preventionTips":["Use only documented year values","Validate settings before deploying"],"tags":["zlibrary","config","validation"],"backgroundTag":"config-value-invalid","analyzedSha":"9fea41204fdfa7a5cfa15b0ebd12904c520478ce","analyzedAt":"2026-08-27T06:40:00.395Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}