searxng/searxng · error · ValueError
invalid setting year_from: {zlib_year_from}
Error message
invalid setting year_from: {zlib_year_from} What it means
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.
Source
Thrown at searx/engines/zlibrary.py:92
zlib_ext: str = ""
"""Filter z-library's results by a file ending. Common filters for example are
``PDF`` and ``EPUB``.
"""
i18n_language = gettext("Language")
i18n_book_rating = gettext("Book rating")
i18n_file_quality = gettext("File quality")
def setup(engine_settings: dict[str, t.Any]) -> bool: # pylint: disable=unused-argument
"""Check of engine's settings."""
traits: EngineTraits = EngineTraits(**ENGINE_TRAITS["z-library"])
if zlib_ext and zlib_ext not in traits.custom["ext"]:
raise ValueError(f"invalid setting ext: {zlib_ext}")
if zlib_year_from and zlib_year_from not in traits.custom["year_from"]:
raise ValueError(f"invalid setting year_from: {zlib_year_from}")
if zlib_year_to and zlib_year_to not in traits.custom["year_to"]:
raise ValueError(f"invalid setting year_to: {zlib_year_to}")
return True
def request(query: str, params: "OnlineParams") -> None:
lang: str | None = traits.get_language(params["searxng_locale"], traits.all_locale)
search_url: str = (
base_url
+ "/s/{search_query}/?page={pageno}"
+ "&yearFrom={zlib_year_from}"
+ "&yearTo={zlib_year_to}"
+ "&languages[]={lang}"
+ "&extensions[]={zlib_ext}"
)
params["url"] = search_url.format(
search_query=quote(query),
pageno=params["pageno"],View on GitHub (pinned to 9fea41204f)
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
Example fix
# before zlib_year_from: 1500 # after zlib_year_from: 1800
Defensive patterns
Strategy: validation
Validate before calling
from searx.engines.zlibrary import ENGINE_TRAITS assert zlib_year_from in ENGINE_TRAITS['z-library']['custom']['year_from']
Try / catch
try:
setup(engine_settings)
except ValueError as e:
logger.error('bad year_from: %s', e) Prevention
- Use only documented year values
- Validate settings before deploying
When it happens
Trigger: Configuring zlib_year_from in settings.yml with a year not in the supported list (e.g. 1800 or a future year).
Common situations: User sets an arbitrary year range without knowing the supported set.
Related errors
- invalid setting ext: {zlib_ext}
- invalid setting year_to: {zlib_year_to}
- zlibrary domain is seized: {base_url}
- Invalid value for use_default_settings
- {obj_name} should be list or dict
AI-assisted analysis of searxng/searxng@9fea41204f (2026-08-27).
Data as JSON: /api/errors/ff5f2258c4a15b73.
Report an issue: GitHub.