From 0146345b883b35aad6c7cee6a467153b8bbbd6f1 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Mar 2026 01:00:45 +0000 Subject: [PATCH] fix: tighten target error hint coverage --- src/infra/outbound/target-errors.test.ts | 10 ++++++++++ src/infra/outbound/target-errors.ts | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/infra/outbound/target-errors.test.ts b/src/infra/outbound/target-errors.test.ts index fb43f5279bf..55750c86b86 100644 --- a/src/infra/outbound/target-errors.test.ts +++ b/src/infra/outbound/target-errors.test.ts @@ -19,6 +19,16 @@ describe("target error helpers", () => { ); }); + it("treats blank hints the same as no hint", () => { + expect(missingTargetMessage("Slack", " ")).toBe("Delivering to Slack requires target"); + expect(ambiguousTargetMessage("Discord", "general", " ")).toBe( + 'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.', + ); + expect(unknownTargetMessage("Discord", "general", " ")).toBe( + 'Unknown target "general" for Discord.', + ); + }); + it("formats ambiguous and unknown target messages with labeled hints", () => { expect(ambiguousTargetMessage("Discord", "general")).toBe( 'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.', diff --git a/src/infra/outbound/target-errors.ts b/src/infra/outbound/target-errors.ts index 0bf589817ac..eedaf66631b 100644 --- a/src/infra/outbound/target-errors.ts +++ b/src/infra/outbound/target-errors.ts @@ -23,8 +23,9 @@ export function unknownTargetError(provider: string, raw: string, hint?: string) } function formatTargetHint(hint?: string, withLabel = false): string { - if (!hint) { + const normalized = hint?.trim(); + if (!normalized) { return ""; } - return withLabel ? ` Hint: ${hint}` : ` ${hint}`; + return withLabel ? ` Hint: ${normalized}` : ` ${normalized}`; }