Relationships
#642 model search --json returns a bare model object instead of {query, results} when exactly one model matches
Opened by jentz · 6/12/2026· Shipped 6/15/2026
Summary
swamp model search <query> --json returns a { "query": ..., "results": [...] }
envelope when zero or multiple models match, but returns a bare,
fully-hydrated model object (the same shape as swamp model get --json —
including globalArguments, globalArgumentsSchema, methods, and schemas)
when exactly one model matches. Scripts and agents that parse .results[]
break on the single-match case.
Environment
- swamp
20260611.205205.0-sha.ad439a70(latest;swamp update --checkreportsup_to_date) - macOS, arm64
- Behavior is model-type-independent.
Steps to reproduce
With several models in a repo, run a substring query that matches more than one model, then one that matches exactly one:
# query matching multiple models -> envelope shape
swamp model search <query-matching-many> --json | jq 'keys'
# ["query", "results"]
# query matching exactly one model -> bare model-get shape
swamp model search <query-matching-one> --json | jq 'keys'
# ["globalArguments", "globalArgumentsSchema", "id", "methods", "name", "tags", "type", "typeVersion", "version"]A query matching zero models also returns the { query, results }
envelope (with an empty results), so the bare-object shape is unique to the
exactly-one case.
Expected
The same envelope shape regardless of match count:
{ "query": "<q>", "results": [ { "id": "...", "name": "...", "type": "..." } ] }Actual
Single-match queries return the full model object directly (no query /
results keys), so jq '.results[]' fails with
Cannot iterate over null (null).
Impact
Automation that "searches before acting" (e.g. checking whether a model with a given name already exists) must special-case the single-result shape. It also emits full schemas (hundreds of lines) when the caller only wanted a name/id listing.
Suggested fix
Always return the { query, results } envelope from model search; keep the
hydrated single-object output on model get.
Shipped
Click a lifecycle step above to view its details.