avoid task id collisions for urls FilterQueryParams cannot parse - #4912
Open
saddamr3e wants to merge 1 commit into
Open
avoid task id collisions for urls FilterQueryParams cannot parse#4912saddamr3e wants to merge 1 commit into
saddamr3e wants to merge 1 commit into
Conversation
Signed-off-by: Saddam <saddamr3e@gmail.com>
saddamr3e
requested review from
ClementMaH,
CooooolFrog,
Zephyrcf,
gaius-qi and
yyzai384
August 3, 2026 13:02
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4912 +/- ##
==========================================
+ Coverage 28.08% 28.47% +0.39%
==========================================
Files 232 235 +3
Lines 23153 23238 +85
==========================================
+ Hits 6502 6618 +116
+ Misses 16211 16172 -39
- Partials 440 448 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Description
FilterQueryParamsrebuilds the query fromu.Query(), which keeps only the pairsurl.ParseQuerycould decode and throws the error away, so?foo=%zzand?foo=%yyboth canonicalize to
https://example.com. On the error path bothidgenhelperssubstituted
"", so every url that failsurl.Parsehashes toSHA256(""):Parse the raw query directly so the error reaches the caller, and keep the raw url in
taskIDV1/TaskIDV2ByURLBasedwhen filtering fails.Related Issue
N/A
Motivation and Context
The scheduler recomputes the task id server side from the peer-supplied url
(
scheduler/rpcserver/scheduler_server_v1.go:56, and theTaskIDV2ByURLBasedcalls inscheduler/service/service_v2.go), so two peers requesting different urls that collideon one id get put on the same task and can be served each other's pieces.
Both triggers are ordinary fetchable urls, not just malformed ones: an invalid percent
escape such as
?discount=100%, and;separated params, whichParseQueryhasrejected since Go 1.17. Neither reaches the sink through a caller that could pre-validate,
since the id is derived inside these helpers.
Task ids for well-formed urls are unchanged.
u.Query()isParseQuery(u.RawQuery)withthe error dropped, so the filtering path is identical when the query decodes, and the
fixed-hash cases already in
task_id_test.gostill pass. A url that now fails to filterkeeps its signature query params in the id, which costs deduplication for that url rather
than merging it with an unrelated one.
Types of changes
Checklist