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:
parent
d1c248a8f4
commit
7953150db9
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue