[workers-utils] Bounds-check nested observability head_sampling_rate values - #15011
Open
LeSingh1 wants to merge 1 commit into
Open
[workers-utils] Bounds-check nested observability head_sampling_rate values#15011LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…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.
workers-devprod
requested review from
a team and
petebacondarwin
and removed request for
a team
August 4, 2026 04:04
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
validateObservabilitybounds-checkshead_sampling_rateonly at the top level. The nestedobservability.logs.head_sampling_rateandobservability.traces.head_sampling_rateare 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-isThis extracts the existing check into
validateHeadSamplingRateand 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.)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.