downloader: fix SAS token corruption in constructDatastoreContext#5715
Conversation
|
|
||
| // Reattach the raw query string after the path has been assembled. | ||
| // We do not re-encode it: the caller is responsible for passing a | ||
| // correctly percent-encoded query string in configName. |
There was a problem hiding this comment.
The caller is responsible for passing a correctly percent-encoded query string in configName.
Is the caller here the controller or the user? In the latter case, we should make sure this requirement is documented.
|
Needs to be rebased on master for the eden tests to work |
bcaee89 to
321feb2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5715 +/- ##
==========================================
+ Coverage 19.52% 28.34% +8.81%
==========================================
Files 19 18 -1
Lines 3021 2417 -604
==========================================
+ Hits 590 685 +95
+ Misses 2310 1588 -722
- Partials 121 144 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
321feb2 to
aa4b885
Compare
url.JoinPath() percent-encodes '?' to '%3F' when it appears inside a path segment argument. When configName contains a query string (e.g. an Azure SAS token: ?st=...&se=...&sig=...), the entire query string is mangled into the path, causing Azure Blob Storage to return HTTP 409 on the resulting URL. Split configName on the first '?' before calling url.JoinPath, apply the path join only to the clean path portion, then reattach the raw query string after assembly. This preserves SAS tokens and any other query-string credentials embedded in the relative URL. The regression was introduced when simple string concatenation was replaced with url.JoinPath (13.4-stable -> 16.7.0). The old concat preserved '?' literally; url.JoinPath correctly encodes it as a path character, breaking datastores configured with HTTP type and a SAS-bearing relative URL. Fixes: app instances stuck in DOWNLOADING state with HTTP 409 from Azure Blob Storage when datastore is configured as HTTP type with a SAS token in the relative URL field. Signed-off-by: Ioannis Sfakianakis <jsfakas@gmail.com>
aa4b885 to
ac8396d
Compare
|
Updates:
|
|
@jsfakian please take another look at the backporting section - I think this fix needs to be marked as stable and backported |
|
@jsfakian I backported the fix to 16.0-stable, but 14.5 and 13.4 still need to be done |
Description
url.JoinPath()percent-encodes?to%3Fwhen it appears insidea path segment argument. When
configNamecontains a query string(e.g. an Azure SAS token:
?st=...&se=...&sig=...), the entire querystring is mangled into the path, causing Azure Blob Storage to return
HTTP 409 on the resulting URL, leaving the app instance permanently
stuck in
DOWNLOADINGstate.Split
configNameon the first?before callingurl.JoinPath,apply the path join only to the clean path portion, then reattach the
raw query string after assembly. This preserves SAS tokens and any
other query-string credentials embedded in the relative URL.
The regression was introduced when simple string concatenation was
replaced with
url.JoinPath(13.4-stable → 16.7.0). The oldconcatenation preserved
?literally;url.JoinPathcorrectlyencodes it as a path character, breaking datastores configured as HTTP
type with a SAS-bearing relative URL.
How to test and validate this PR
Prerequisites:
datastore pointing to Azure Blob Storage, where the relative URL
contains a SAS token (i.e., the URL contains
?st=...&sig=...)Steps to verify the fix:
datastore pointing to Azure Blob Storage, where the relative URL
contains a SAS token (i.e., the URL contains
?st=...&sig=...)%3Finthe logged URL,
CurrentSizeincrements in the downloader statusDOWNLOADINGtoRUNNING.Changelog notes
Fixed a regression introduced in 16.0, where application image downloads
from HTTP datastores using Azure SAS tokens (query string credentials
in the relative URL field) failed with HTTP 409, leaving the application
permanently stuck in the
DOWNLOADINGstate. The fix correctlypreserves the SAS query string when constructing the download URL.
PR Backports
Checklist
check them.