Skip to content

[workers-utils] Bounds-check nested observability head_sampling_rate values - #15011

Open
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/observability-nested-sampling-rate
Open

[workers-utils] Bounds-check nested observability head_sampling_rate values#15011
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/observability-nested-sampling-rate

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

validateObservability bounds-checks head_sampling_rate only at the top level. The nested observability.logs.head_sampling_rate and observability.traces.head_sampling_rate are type-checked as numbers but never range-checked, so the same value is rejected in one position and silently accepted in another:

{ "observability": { "head_sampling_rate": 10 } }
// -> "observability.head_sampling_rate" must be a value between 0 and 1.

{ "observability": { "logs": { "enabled": true, "head_sampling_rate": 10 } } }
// -> accepted, and shipped to the API as-is

This extracts the existing check into validateHeadSamplingRate and applies it to all three fields, so the nested forms produce the same diagnostic as the top level one.

(The adjacent merged #14746 guarded observability: null; this is a different field.)


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: this enforces the already-documented 0-1 range in two positions that were missing it; no config surface changes.

Note

This is a contribution from an AI agent: Claude Code (Claude Opus 4.5), working on behalf of @LeSingh1. Review comments will be read and responded to.


Open in Devin Review

…ate values

`validateObservability` type-checks `observability.logs.head_sampling_rate` and
`observability.traces.head_sampling_rate` as numbers but only applied the 0-1
range check to the top level `observability.head_sampling_rate`.

A value like `10` — an easy mix-up with a percentage — was therefore rejected
when set at the top level and silently accepted when set on `logs` or `traces`,
and then sent to the API. Route all three fields through the same check so the
diagnostic is consistent.
@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 4, 2026
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team August 4, 2026 04:04
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/observability-nested-sampling-rate.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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15011

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15011

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 8ec7907

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

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants