fix(cli): make commands, completion, and JSON output reliable (#116033)

* fix(cli): make commands, completion, and JSON output reliable

* fix(cli): reconcile completion coverage with current main

* test(cli): keep test routing stable across isolation lanes
This commit is contained in:
Peter Steinberger
2026-07-31 16:20:34 -07:00
committed by GitHub
parent 4645d4a487
commit 433bb3f954
70 changed files with 2789 additions and 551 deletions
+23 -10
View File
@@ -107,6 +107,20 @@ function buildUnknownNodePairRequestIdMessage(
return lines.join("\n");
}
function rethrowUnknownNodePairRequestId(
error: unknown,
requestId: string,
opts: NodesRpcOpts,
): never {
if (!isUnknownNodePairRequestIdError(error)) {
throw error;
}
// Reuse the gateway error so generic formatting does not append its raw cause.
error.name = "Error";
error.message = buildUnknownNodePairRequestIdMessage(requestId, opts);
throw error;
}
/** Register node pairing management commands. */
export function registerNodesPairingCommands(nodes: Command) {
nodesCallOpts(
@@ -162,13 +176,7 @@ export function registerNodesPairingCommands(nodes: Command) {
},
);
} catch (error) {
if (!isUnknownNodePairRequestIdError(error)) {
throw error;
}
// Reuse the gateway error so generic formatting does not append its raw cause.
error.name = "Error";
error.message = buildUnknownNodePairRequestIdMessage(requestId, opts);
throw error;
rethrowUnknownNodePairRequestId(error, requestId, opts);
}
defaultRuntime.writeJson(result);
});
@@ -182,9 +190,14 @@ export function registerNodesPairingCommands(nodes: Command) {
.argument("<requestId>", "Pending request id")
.action(async (requestId: string, opts: NodesRpcOpts) => {
await runNodesCommand("reject", async () => {
const result = await callGatewayCli("node.pair.reject", opts, {
requestId,
});
let result: unknown;
try {
result = await callGatewayCli("node.pair.reject", opts, {
requestId,
});
} catch (error) {
rethrowUnknownNodePairRequestId(error, requestId, opts);
}
defaultRuntime.writeJson(result);
});
}),