fix(notifier): gate missing-config warnings on AO_QUIET_STARTUP

Warnings were removed unconditionally, so misconfigured notifiers
silently became no-ops for all callers. Now warnings only suppress
during ao start (AO_QUIET_STARTUP=1); SDK consumers, tests, and other
CLI commands still receive diagnostic feedback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-05-20 21:01:47 +00:00
parent d1c248a8f4
commit 7953150db9
4 changed files with 28 additions and 4 deletions

View File

@ -59,10 +59,18 @@ describe("notifier-slack", () => {
expect(notifier.name).toBe("slack");
});
it("is silent when no webhookUrl configured (no-op notifier)", () => {
it("warns when no webhookUrl configured", () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
create();
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("No webhookUrl configured"));
});
it("is silent when no webhookUrl configured and AO_QUIET_STARTUP is set", () => {
process.env.AO_QUIET_STARTUP = "1";
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
create();
expect(warnSpy).not.toHaveBeenCalled();
delete process.env.AO_QUIET_STARTUP;
});
it("throws on invalid URL scheme", () => {

View File

@ -357,7 +357,11 @@ export function create(config?: Record<string, unknown>): Notifier {
const defaultChannel = config?.channel as string | undefined;
const username = (config?.username as string) ?? "Agent Orchestrator";
if (webhookUrl) {
if (!webhookUrl) {
if (!process.env.AO_QUIET_STARTUP) {
console.warn("[notifier-slack] No webhookUrl configured — notifications will be no-ops");
}
} else {
validateUrl(webhookUrl, "notifier-slack");
}

View File

@ -39,10 +39,18 @@ describe("notifier-webhook", () => {
expect(notifier.name).toBe("webhook");
});
it("is silent when no url configured (no-op notifier)", () => {
it("warns when no url configured", () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
create();
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("No url configured"));
});
it("is silent when no url configured and AO_QUIET_STARTUP is set", () => {
process.env.AO_QUIET_STARTUP = "1";
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
create();
expect(warnSpy).not.toHaveBeenCalled();
delete process.env.AO_QUIET_STARTUP;
});
it("throws on invalid URL scheme", () => {

View File

@ -107,7 +107,11 @@ export function create(config?: Record<string, unknown>): Notifier {
}
const { retries, retryDelayMs } = normalizeRetryConfig(config);
if (url) {
if (!url) {
if (!process.env.AO_QUIET_STARTUP) {
console.warn("[notifier-webhook] No url configured — notifications will be no-ops");
}
} else {
validateUrl(url, "notifier-webhook");
}