Skip to content

Commit 561d233

Browse files
committed
fix(kiloclaw): wrap pre-destroy getDebugStatus in error handler
The ownership check in destroyFlyMachine called getDebugStatus outside the try/catch, so a KiloClawApiError from a temporarily unavailable DO would bubble up as a raw internal error instead of going through throwKiloclawAdminError like every other mutation in the router.
1 parent 22b56cf commit 561d233

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/routers/admin-kiloclaw-instances-router.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,12 @@ export const adminKiloclawInstancesRouter = createTRPCRouter({
652652
const client = new KiloClawInternalClient();
653653

654654
// Verify the appName/machineId match the DO's actual state
655-
const status = await client.getDebugStatus(input.userId);
655+
let status: Awaited<ReturnType<KiloClawInternalClient['getDebugStatus']>>;
656+
try {
657+
status = await client.getDebugStatus(input.userId);
658+
} catch (err) {
659+
throwKiloclawAdminError(err, 'Failed to verify machine state before destroy');
660+
}
656661
if (status.flyAppName !== input.appName || status.flyMachineId !== input.machineId) {
657662
throw new TRPCError({
658663
code: 'BAD_REQUEST',

0 commit comments

Comments
 (0)