fix(codex): treat a literal null from the CLI as an empty list, not a 500

This commit is contained in:
2026-09-09 01:29:17 +07:00
parent 42db57ee18
commit ed418d5696
2 changed files with 17 additions and 2 deletions
+4 -2
View File
@@ -258,8 +258,10 @@ async function mcpRemove(name) {
*/
async function pluginList() {
const result = await runCodex(["plugin", "list", "--json"]);
// `data` is null when stdout was the literal `null` — JSON that parses to
// nothing. Guard it: a CLI's output must never reach the route as a 500.
if (result.data !== undefined && !Array.isArray(result.data)) {
result.data = Array.isArray(result.data.installed) ? result.data.installed : [];
result.data = Array.isArray(result.data?.installed) ? result.data.installed : [];
}
return result;
}
@@ -283,7 +285,7 @@ async function pluginRemove(spec) {
async function marketplaceList() {
const result = await runCodex(["plugin", "marketplace", "list", "--json"]);
if (result.data !== undefined && !Array.isArray(result.data)) {
result.data = Array.isArray(result.data.marketplaces) ? result.data.marketplaces : [];
result.data = Array.isArray(result.data?.marketplaces) ? result.data.marketplaces : [];
}
return result;
}