From 8183be0da508b3d5fa3ae9635fce4534e98632e3 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Tue, 13 Oct 2026 14:44:40 +0000 Subject: [PATCH] Section 31 point 2: fix the toggle spec and the exec output types --- startos/actions/deleteHistory.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/startos/actions/deleteHistory.ts b/startos/actions/deleteHistory.ts index 6cf37db..1bbb5ee 100644 --- a/startos/actions/deleteHistory.ts +++ b/startos/actions/deleteHistory.ts @@ -5,12 +5,13 @@ import { dataMountpoint, imageId, volumeId } from '../utils' const { InputSpec, Value } = sdk // The history cannot be recovered once it is gone, so the action takes a -// mandatory confirmation and refuses to run without it (section 31 point 2). +// confirmation box, and the handler refuses to run without it (section 31 +// point 2). A toggle has no `required` flag, so the confirmation is enforced in +// the handler. const inputSpec = InputSpec.of({ confirm: Value.toggle({ name: i18n('I confirm that the stored history will be deleted and cannot be recovered'), description: null, - required: true, default: false, }), }) @@ -60,9 +61,12 @@ export const deleteHistory = sdk.Action.withInput( async (sub) => { const result = await sub.exec(['python3', 'maintenance.py', 'delete-history']) if (result.exitCode !== 0) { - throw new Error(result.stderr.trim() || i18n('The history could not be deleted.')) + // exec() returns stdout/stderr as either text or bytes, so both are + // normalised before they are used. + const stderr = String(result.stderr).trim() + throw new Error(stderr || i18n('The history could not be deleted.')) } - report = result.stdout.trim() + report = String(result.stdout).trim() }, )