tinyhumansai/openhuman · error

categories must contain only strings

Error message

categories must contain only strings

What it means

Element-type guard in parse_search_args: "categories" is an array but at least one element is not a JSON string (e.g. a number or nested object), so it cannot be mapped to a SearXNG category name. The faulting input is an array containing non-string items.

Source

Thrown at src/openhuman/search/tools/searxng.rs:403

        .as_object()
        .ok_or_else(|| anyhow::anyhow!("SearXNG arguments must be an object"))?;
    let query = object
        .get("query")
        .and_then(|value| value.as_str())
        .map(str::trim)
        .filter(|value| !value.is_empty())
        .ok_or_else(|| anyhow::anyhow!("Missing required parameter: query"))?
        .to_string();
    let categories = match object.get("categories") {
        Some(value) if value.is_null() => Vec::new(),
        Some(value) => value
            .as_array()
            .ok_or_else(|| anyhow::anyhow!("categories must be an array of strings"))?
            .iter()
            .map(|item| {
                item.as_str()
                    .map(str::to_string)
                    .ok_or_else(|| anyhow::anyhow!("categories must contain only strings"))
            })
            .collect::<anyhow::Result<Vec<_>>>()?,
        None => Vec::new(),
    };
    let language = match object.get("language") {
        Some(value) => {
            let language = value
                .as_str()
                .map(str::trim)
                .filter(|value| !value.is_empty())
                .ok_or_else(|| anyhow::anyhow!("language must be a non-empty string"))?;
            Some(language.to_string())
        }
        None => None,
    };
    let max_results = match object.get("max_results") {
        Some(value) => {
            let max_results = value

View on GitHub (pinned to 7491200858)

Solutions

  1. Ensure every element of the categories array is a string, e.g. ["general"] not [1].
  2. Use valid SearXNG category names (general, images, news, it, science, files, music, videos, social media).
  3. Sanitize model-generated arrays before passing them through.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/openhuman/search/tools/searxng.rs:403 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/5e661d57b47df76d. Report an issue: GitHub.