Skip to content

Commit 0146345

Browse files
committed
fix: tighten target error hint coverage
1 parent 25f458a commit 0146345

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/infra/outbound/target-errors.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ describe("target error helpers", () => {
1919
);
2020
});
2121

22+
it("treats blank hints the same as no hint", () => {
23+
expect(missingTargetMessage("Slack", " ")).toBe("Delivering to Slack requires target");
24+
expect(ambiguousTargetMessage("Discord", "general", " ")).toBe(
25+
'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.',
26+
);
27+
expect(unknownTargetMessage("Discord", "general", " ")).toBe(
28+
'Unknown target "general" for Discord.',
29+
);
30+
});
31+
2232
it("formats ambiguous and unknown target messages with labeled hints", () => {
2333
expect(ambiguousTargetMessage("Discord", "general")).toBe(
2434
'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.',

src/infra/outbound/target-errors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export function unknownTargetError(provider: string, raw: string, hint?: string)
2323
}
2424

2525
function formatTargetHint(hint?: string, withLabel = false): string {
26-
if (!hint) {
26+
const normalized = hint?.trim();
27+
if (!normalized) {
2728
return "";
2829
}
29-
return withLabel ? ` Hint: ${hint}` : ` ${hint}`;
30+
return withLabel ? ` Hint: ${normalized}` : ` ${normalized}`;
3031
}

0 commit comments

Comments
 (0)