mvanhorn/last30days-skill · error · ValueError

field 'subqueries' must be a non-empty array

Error message

field 'subqueries' must be a non-empty array

What it means

validate_external_plan requires 'subqueries' to be a non-empty list. An empty plan with zero subqueries, a dict of subqueries keyed by name, or a bare string all fail here. At least one subquery is mandatory because it defines the actual search work; a plan with nothing to run is meaningless.

Source

Thrown at skills/last30days/scripts/lib/planner.py:191

            raise ValueError(f"missing required field '{field}'")
    for field in ("intent", "freshness_mode", "cluster_mode"):
        if not isinstance(raw[field], str) or not raw[field].strip():
            raise ValueError(f"field '{field}' must be a non-empty string")

    source_weights = raw.get("source_weights")
    if source_weights is not None and not isinstance(source_weights, dict):
        raise ValueError("field 'source_weights' must be an object when provided")
    for source, weight in (source_weights or {}).items():
        if (
            not isinstance(source, str)
            or not source.strip()
            or isinstance(weight, bool)
            or not isinstance(weight, (int, float))
        ):
            raise ValueError("field 'source_weights' must map source names to numbers")
    subqueries = raw["subqueries"]
    if not isinstance(subqueries, list) or not subqueries:
        raise ValueError("field 'subqueries' must be a non-empty array")
    for index, subquery in enumerate(subqueries):
        if not isinstance(subquery, dict):
            raise ValueError(f"subqueries[{index}] must be an object")
        for field in ("search_query", "ranking_query"):
            if not isinstance(subquery.get(field), str) or not subquery[field].strip():
                raise ValueError(f"subqueries[{index}].{field} must be a non-empty string")
        sources = subquery.get("sources")
        if not isinstance(sources, list) or not sources or not all(
            isinstance(source, str) and source.strip() for source in sources
        ):
            raise ValueError(f"subqueries[{index}].sources must be a non-empty string array")
        weight = subquery.get("weight")
        if weight is not None and (
            isinstance(weight, bool) or not isinstance(weight, (int, float))
        ):
            raise ValueError(f"subqueries[{index}].weight must be a number when provided")

View on GitHub (pinned to c7460f6114)

Solutions

  1. Provide at least one subquery object with search_query, ranking_query, and sources.
  2. If the generator produced none, fall back to letting the planner build the plan instead of passing external_plan.
  3. Guard in your emitter: if not plan['subqueries']: skip the external plan.

Example fix

# before
"subqueries": []

# after
"subqueries": [{"search_query": "rust compilers", "ranking_query": "rust compiler performance", "sources": ["reddit", "hackernews"]}]
Defensive patterns

Strategy: validation

Validate before calling

sq = plan["subqueries"]
if not isinstance(sq, list) or not sq:
    raise SystemExit("external plan needs >= 1 subquery")

Type guard

def is_nonempty_subquery_list(v) -> bool:
    return isinstance(v, list) and len(v) > 0 and all(isinstance(q, dict) for q in v)

Prevention

When it happens

Trigger: "subqueries": [] or "subqueries": {} or "subqueries": "q: rust compilers" in the external plan.

Common situations: LLM generating an empty array when it finds nothing worth searching; template scaffolds left unpopulated; subqueries accidentally nested one level too deep so the top field is empty.

Related errors


AI-assisted analysis of mvanhorn/last30days-skill@c7460f6114 (2026-08-15). Data as JSON: /api/errors/8df2e8b9e1b958b1. Report an issue: GitHub.