From 87b6b54223419f14c725f7b1b40e510ecf8b32dd Mon Sep 17 00:00:00 2001 From: ExtraBrain Developer Date: Sun, 18 Oct 2026 08:46:06 +0200 Subject: [PATCH] Report missing required profile text fields as required Creating a profile or profile action without --prompt failed with "prompt must be text of at most 1000 characters", which points at the wrong problem. The shared text check now reports " is required" when a required field is absent, and keeps the length message for values that are too long. Co-Authored-By: Claude Opus 5.5 --- src/profileCommands.service.ts | 5 ++++- test/profileCommands.service.test.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/profileCommands.service.ts b/src/profileCommands.service.ts index 5bdd45e..c16804e 100644 --- a/src/profileCommands.service.ts +++ b/src/profileCommands.service.ts @@ -110,7 +110,10 @@ const assertKeys = (input: JsonObject, allowed: readonly string[], label: string const text = (input: JsonObject, key: string, max: number, requiredField: boolean): void => { const value = input[key] - if (value === undefined && !requiredField) return + if (value === undefined) { + if (requiredField) throw new Error(`${key} is required`) + return + } if (typeof value !== 'string' || value.length > max) throw new Error(`${key} must be text of at most ${max} characters`) } diff --git a/test/profileCommands.service.test.ts b/test/profileCommands.service.test.ts index a05c2a0..8bff418 100644 --- a/test/profileCommands.service.test.ts +++ b/test/profileCommands.service.test.ts @@ -93,6 +93,15 @@ describe('profile commands', () => { expect(test.errors[1]).toContain('supported profile icon') }) + it('reports a missing required text field as required, not as too long', async () => { + const json: JsonMock = vi.fn(async () => ({ revision: 9 })) + const test = harness(json) + await expect(runCli(['profiles', 'actions', 'create', 'custom', 'profile1', '--name', 'n'], test.dependencies)).resolves.toBe(CliExitCode.USAGE) + await expect(runCli(['profiles', 'create', '--name', 'n', '--description', 'd'], test.dependencies)).resolves.toBe(CliExitCode.USAGE) + expect(test.errors).toEqual([expect.stringContaining('prompt is required'), expect.stringContaining('prompt is required')]) + expect(json).not.toHaveBeenCalled() + }) + it('rejects unknown, inapplicable, impossible, and trailing input before opening a profile request', async () => { const json: JsonMock = vi.fn(async () => ({ revision: 9 })) const test = harness(json)