From 8a9bcb049ce7b41173ff002997ea9a2930183666 Mon Sep 17 00:00:00 2001 From: Ankcorn Date: Thu, 21 Nov 2024 13:39:23 +0000 Subject: [PATCH 1/4] fix observability.logs.enabled optional logic --- .../src/__tests__/configuration.test.ts | 23 +++++++++++++++++++ packages/wrangler/src/config/validation.ts | 14 +++++------ 2 files changed, 30 insertions(+), 7 deletions(-) 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..e809114c26c5 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -3384,13 +3384,13 @@ const validateObservability: ValidatorFn = (diagnostics, field, value) => { */ if (typeof val.logs === "object") { isValid = - validateRequiredProperty( - diagnostics, - field, - "logs.enabled", - val.logs.enabled, - "boolean" - ) && isValid; + validateOptionalProperty( + diagnostics, + field, + "logs.enabled", + val.logs.enabled, + "boolean" + ) && isValid; isValid = validateOptionalProperty( From 65e2b8c8605d83525c806ea0027b9dabe029e329 Mon Sep 17 00:00:00 2001 From: Ankcorn Date: Thu, 21 Nov 2024 13:43:13 +0000 Subject: [PATCH 2/4] run lint fix --- packages/wrangler/src/config/validation.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index e809114c26c5..1315019110df 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -3384,13 +3384,13 @@ const validateObservability: ValidatorFn = (diagnostics, field, value) => { */ if (typeof val.logs === "object") { isValid = - validateOptionalProperty( - diagnostics, - field, - "logs.enabled", - val.logs.enabled, - "boolean" - ) && isValid; + validateOptionalProperty( + diagnostics, + field, + "logs.enabled", + val.logs.enabled, + "boolean" + ) && isValid; isValid = validateOptionalProperty( From b266a31cdd77a53d1a818a880098d3350a19e105 Mon Sep 17 00:00:00 2001 From: Ankcorn Date: Thu, 21 Nov 2024 13:44:37 +0000 Subject: [PATCH 3/4] add changeset --- .changeset/lemon-buckets-know.md | 5 +++++ 1 file changed, 5 insertions(+) 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..9e870b20cbd1 --- /dev/null +++ b/.changeset/lemon-buckets-know.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Fix observability.logs.enabled validation From fd68a91af6e61df1ea7189fb794abd5a0dbb88bd Mon Sep 17 00:00:00 2001 From: Thomas Ankcorn Date: Thu, 21 Nov 2024 13:52:30 +0000 Subject: [PATCH 4/4] Update .changeset/lemon-buckets-know.md Co-authored-by: Edmund Hung --- .changeset/lemon-buckets-know.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lemon-buckets-know.md b/.changeset/lemon-buckets-know.md index 9e870b20cbd1..8ab72f884b24 100644 --- a/.changeset/lemon-buckets-know.md +++ b/.changeset/lemon-buckets-know.md @@ -1,5 +1,5 @@ --- -"wrangler": minor +"wrangler": patch --- Fix observability.logs.enabled validation