Skip to content

The agent that grows with you

fix(desktop): a malformed catalog lookup reply reads as unavailable; the gateway validates names with the CLI's own rule

Brooklyn Nicholsonda2881e1b026
diff --git a/apps/desktop/src/lib/plugin-catalog.test.ts b/apps/desktop/src/lib/plugin-catalog.test.ts
index 88562c9f614..d08f862bb5b 100644
--- a/apps/desktop/src/lib/plugin-catalog.test.ts
+++ b/apps/desktop/src/lib/plugin-catalog.test.ts
@@ -37,7 +37,9 @@ describe('lookupPluginCatalogEntry', () => {
[{ status: 'invalid_name' }, 'invalid_name'],
[{ status: 'unavailable' }, 'unavailable'],
[{ status: 'found', entry: { name: 'x' } }, 'unavailable'],
- [{ status: 'something-new' }, 'unavailable']
+ [{ status: 'something-new' }, 'unavailable'],
+ [null, 'unavailable'],
+ [undefined, 'unavailable']
] as const)('backend %j → %s, with no fetch', async (reply, error) => {
await expect(
lookupPluginCatalogEntry('weather', { fetchImpl: noFetch, request: replying(reply) })
diff --git a/apps/desktop/src/lib/plugin-catalog.ts b/apps/desktop/src/lib/plugin-catalog.ts
index dfb786ebdc2..409ade35869 100644
--- a/apps/desktop/src/lib/plugin-catalog.ts
+++ b/apps/desktop/src/lib/plugin-catalog.ts
@@ -122,7 +122,7 @@ export async function lookupPluginCatalogEntry(
return { ok: false, error: 'invalid_name' }
}
- let reply: CatalogLookupReply
+ let reply: CatalogLookupReply | null | undefined
try {
reply = await request<CatalogLookupReply>('plugins.catalog.lookup', { name: trimmed })
@@ -130,14 +130,17 @@ export async function lookupPluginCatalogEntry(
return lookupFromFeed(trimmed, fetchImpl)
}
- if (reply.status === 'found') {
- const entry = asEntry(reply.entry)
+ // A malformed success reply (null, no status) degrades like every other failure.
+ const status = reply?.status
+
+ if (status === 'found') {
+ const entry = asEntry(reply?.entry)
return entry ? { ok: true, entry } : { ok: false, error: 'unavailable' }
}
return {
ok: false,
- error: reply.status === 'unknown' || reply.status === 'invalid_name' ? reply.status : 'unavailable'
+ error: status === 'unknown' || status === 'invalid_name' ? status : 'unavailable'
}
}
diff --git a/tui_gateway/methods_plugin_catalog.py b/tui_gateway/methods_plugin_catalog.py
index 0ce3530a4e2..f9b09f61aef 100644
--- a/tui_gateway/methods_plugin_catalog.py
+++ b/tui_gateway/methods_plugin_catalog.py
@@ -21,10 +21,11 @@ _profile_scoped = _registry.profile_scoped
@method("plugins.catalog.lookup")
@_profile_scoped
def _(rid, params: dict) -> dict:
- from hermes_cli.plugin_catalog import _NAME_RE, find_removed, load_catalog_live
+ from hermes_cli.plugin_catalog import find_removed, load_catalog_live
+ from hermes_cli.plugins_cmd_catalog import looks_like_catalog_name
name = str(params.get("name") or "").strip()
- if not _NAME_RE.match(name):
+ if not looks_like_catalog_name(name): # the same rule `hermes plugins install <name>` applies
return _ok(rid, {"status": "invalid_name"})
# The loaders never raise: a dead host falls back to the cache, then to the in-tree catalog.
# Nothing readable at all is "unavailable", never a guess.