From a30c8056621f44063082a81d06f10e723844059f Mon Sep 17 00:00:00 2001 From: Thomas Ankcorn Date: Thu, 21 Nov 2024 14:17:21 +0000 Subject: [PATCH] Fix/workers observability logs (#7314) * fix observability.logs.enabled optional logic * run lint fix * add changeset * Update .changeset/lemon-buckets-know.md Co-authored-by: Edmund Hung --------- Co-authored-by: Edmund Hung --- .changeset/lemon-buckets-know.md | 5 ++++ .../src/__tests__/configuration.test.ts | 23 +++++++++++++++++++ packages/wrangler/src/config/validation.ts | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .changeset/lemon-buckets-know.md diff --git a/.changeset/lemon-buckets-know.md b/.changeset/lemon-buckets-know.md new file mode 100644 index 000000000000..8ab72f884b24 --- /dev/null +++ b/.changeset/lemon-buckets-know.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Fix observability.logs.enabled validation diff --git a/packages/wrangler/src/__tests__/configuration.test.ts b/packages/wrangler/src/__tests__/configuration.test.ts index 35ece1dcf03a..0a56c2f9fda0 100644 --- a/packages/wrangler/src/__tests__/configuration.test.ts +++ b/packages/wrangler/src/__tests__/configuration.test.ts @@ -5537,6 +5537,29 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.hasErrors()).toBe(false); }); + + it("should not error on mixed observability config", () => { + const { diagnostics } = normalizeAndValidateConfig( + { + observability: { + enabled: true, + logs: { + invocation_logs: false, + }, + }, + } as unknown as RawConfig, + undefined, + { env: undefined } + ); + + expect(diagnostics.hasWarnings()).toBe(false); + expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` + "Processing wrangler configuration: + " + `); + + expect(diagnostics.hasErrors()).toBe(false); + }); it("should error on a sampling rate out of range", () => { const { diagnostics } = normalizeAndValidateConfig( { diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index 9bda9ae9fdae..1315019110df 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -3384,7 +3384,7 @@ const validateObservability: ValidatorFn = (diagnostics, field, value) => { */ if (typeof val.logs === "object") { isValid = - validateRequiredProperty( + validateOptionalProperty( diagnostics, field, "logs.enabled",