Skip to content

Commit

Permalink
Fix/workers observability logs (#7314)
Browse files Browse the repository at this point in the history
* fix observability.logs.enabled optional logic

* run lint fix

* add changeset

* Update .changeset/lemon-buckets-know.md

Co-authored-by: Edmund Hung <me@edmund.dev>

---------

Co-authored-by: Edmund Hung <me@edmund.dev>
  • Loading branch information
Ankcorn and edmundhung authored Nov 21, 2024
1 parent 563439b commit a30c805
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lemon-buckets-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Fix observability.logs.enabled validation
23 changes: 23 additions & 0 deletions packages/wrangler/src/__tests__/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3384,7 +3384,7 @@ const validateObservability: ValidatorFn = (diagnostics, field, value) => {
*/
if (typeof val.logs === "object") {
isValid =
validateRequiredProperty(
validateOptionalProperty(
diagnostics,
field,
"logs.enabled",
Expand Down

0 comments on commit a30c805

Please sign in to comment.