Skip to content

Return None from Cf::request_priority for an empty string - #1108

Open
tlq5l wants to merge 1 commit into
cloudflare:mainfrom
tlq5l:fix/request-priority-empty
Open

tlq5l wants to merge 1 commit into
cloudflare:mainfrom
tlq5l:fix/request-priority-empty

Conversation

@tlq5l

@tlq5l tlq5l commented Oct 21, 2026

Copy link
Copy Markdown

Fixes #1106

Cf::request_priority() panicked when requestPriority was an empty string. "".split(';') yields one empty segment, and the parser then called unwrap() on the missing value after splitting on =.

The pairs are now read with split_once('=')?, so an empty string or a segment without key=value returns None. Valid values parse as before. I left the unwrap() on number parsing and the unreachable!() for unknown keys alone (so weight=abc or foo=1 still panic) because the issue does not cover them.

Added wasm tests for the empty string and for a normal value, plus a changeset.

Ran live: cargo test -p worker --target wasm32-unknown-unknown --lib cf:: (wasm-bindgen-test-runner on node) -> the empty-string test panics at cf.rs:86 on the old code and passes with the fix.

@tlq5l
tlq5l requested a review from guybedford as a code owner October 21, 2026 15:22
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.

[BUG] Cf::request_priority() panics when requestPriority is an empty string

2 participants