Skip to content

fix(workers-utils): reject null observability config instead of crashing#14746

Open
samarth70 wants to merge 1 commit into
cloudflare:mainfrom
samarth70:fix/observability-null-validation
Open

fix(workers-utils): reject null observability config instead of crashing#14746
samarth70 wants to merge 1 commit into
cloudflare:mainfrom
samarth70:fix/observability-null-validation

Conversation

@samarth70

@samarth70 samarth70 commented Jul 17, 2026

Copy link
Copy Markdown

There's no existing issue for this; it's a small validation bug found while reading the config validators.

validateObservability guards only against undefined:

if (typeof value !== "object") {

Because typeof null === "object", a null value falls through this check. The function then reads val.enabled, which throws:

TypeError: Cannot read properties of null (reading 'enabled')

null is reachable through real config, since Wrangler accepts JSON/JSONC where "observability": null is valid. Instead of a clean diagnostic, the user gets a stack trace.

The sibling validateCache validator already handles this correctly:

if (typeof value !== "object" || value === null) {

This change brings validateObservability in line with it, so observability: null now produces:

"observability" should be an object but got null.

which matches how every other object-typed field (browser, durable_objects, cache, ...) already reports a null value.

The added test fails on the current code with the TypeError above and passes with the fix. Verified with pnpm test -F @cloudflare/workers-utils (431 passed), plus oxlint and oxfmt clean.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: this corrects an internal validation error path; no user-facing config behavior or documented field changes.

Open in Devin Review

validateObservability only guarded against undefined, so a null value
(valid in JSON/JSONC config) passed the typeof === "object" check and
then threw a TypeError while reading val.enabled. Reject null with the
same diagnostic the sibling cache validator already emits, and add a
regression test.

Signed-off-by: Sam Agarwal <samarthagrawal526@gmail.com>
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 58bdb41

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@cloudflare/workers-utils Patch
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/workers-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team July 17, 2026 15:10
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/observability-null-validation.md: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants