Skip to content

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

Merged
NuroDev merged 1 commit into
cloudflare:mainfrom
samarth70:fix/observability-null-validation
Jul 20, 2026
Merged

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

Conversation

@samarth70

@samarth70 samarth70 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

workers-devprod commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@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

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14746

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@14746

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14746

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14746

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14746

miniflare

npm i https://pkg.pr.new/miniflare@14746

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14746

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14746

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14746

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14746

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14746

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14746

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14746

wrangler

npm i https://pkg.pr.new/wrangler@14746

commit: 58bdb41

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jul 20, 2026
@NuroDev
NuroDev merged commit a6c214f into cloudflare:main Jul 20, 2026
62 of 63 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants