infiniflow/ragflow · error · ValueError
Querit time_range must be a string.
Error message
Querit time_range must be a string.
What it means
ValueError from _validate_search_inputs(): the 'time_range' parameter of Querit search must be a Python str (isinstance check). Any non-string — None, int, list — raises before the format regex (dN/wN/mN/yN or YYYY-MM-DDtoYYYY-MM-DD) is even attempted.
Source
Thrown at agent/tools/querit.py:410
if "statuses" in response_data and not isinstance(response_data["statuses"], list):
raise TypeError("Querit API response field statuses must be an array.")
def _validate_search_inputs(
count: Any,
chunks_per_doc: Any,
time_range: Any,
site_include: Any,
site_exclude: Any,
country_include: Any,
language_include: Any,
) -> None:
if type(count) is not int or count < 1:
raise ValueError("Querit count must be an integer greater than or equal to 1.")
if chunks_per_doc is not None and (type(chunks_per_doc) is not int or not 1 <= chunks_per_doc <= 3):
raise ValueError("Querit chunks_per_doc must be an integer from 1 to 3.")
if type(time_range) is not str:
raise ValueError("Querit time_range must be a string.")
if time_range and not TIME_RANGE_PATTERN.fullmatch(time_range):
raise ValueError("Querit time_range must use dN, wN, mN, yN, or YYYY-MM-DDtoYYYY-MM-DD.")
for name, value in (
("site_include", site_include),
("site_exclude", site_exclude),
("country_include", country_include),
("language_include", language_include),
):
if not isinstance(value, list) or any(not isinstance(item, str) for item in value):
raise ValueError(f"Querit {name} must be an array of strings.")
def _safe_error_message(error: Exception, api_key: str) -> str:
message = str(error) or error.__class__.__name__
return message.replace(api_key, "[REDACTED]") if api_key else message
def _querit_text(value: Any) -> str:View on GitHub (pinned to 554fb1133a)
Solutions
- Pass a string: '' for no filter, or 'd7'/'w2'/'m6'/'y1'/'2024-01-01to2024-12-31'.
- Default None to '' in your caller before invoking.
- Convert numeric day counts: f'd{days}'.
- Flatten single-element arrays to their string item.
Example fix
# before
time_range = None # ValueError (must be str)
# after
time_range = time_range or "" # None-safe
if isinstance(time_range, list) and time_range:
time_range = str(time_range[0]) Defensive patterns
Strategy: validation
Validate before calling
def safe_time_range(v) -> str:
if v is None:
return ""
if isinstance(v, (int, float)) and v > 0:
return f"d{int(v)}"
if isinstance(v, list):
v = str(v[0]) if v else ""
return str(v) Type guard
def is_valid_time_range_type(v) -> bool:
return isinstance(v, str) Try / catch
try:
querit_search._invoke(query=q, time_range=tr)
except ValueError as e:
if "time_range must be a string" in str(e):
tr = safe_time_range(tr); querit_search._invoke(query=q, time_range=tr)
raise Prevention
- Default None to '' before invoking; never leave the field unset in Python calls.
- Use the documented formats: dN/wN/mN/yN or YYYY-MM-DDtoYYYY-MM-DD (also enforced by the follow-up regex check).
- Flatten single-element arrays from workflow bindings to scalars.
When it happens
Trigger: time_range=None when the caller omits it instead of passing '', time_range=['d7'] (list from loosely-typed binding), or time_range=30 (an integer day count from an upstream component).
Common situations: Optional-field templating that leaves None rather than an empty string; workflow engines passing arrays for single-value params; users converting 'last 7 days' to the number 7.
Related errors
- Querit urls must contain between 1 and 10 non-empty strings.
- Querit urls must be absolute HTTP or HTTPS URLs.
- Querit format must be text, markdown, or html.
- Querit crawl_timeout must be an integer from 1 to 60.
- Querit extras_meta must be a boolean.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/369ac9d18c54d8dd.
Report an issue: GitHub.