downloader: fix SAS token corruption in constructDatastoreContext#5715
Open
jsfakian wants to merge 1 commit intolf-edge:masterfrom
Open
downloader: fix SAS token corruption in constructDatastoreContext#5715jsfakian wants to merge 1 commit intolf-edge:masterfrom
jsfakian wants to merge 1 commit intolf-edge:masterfrom
Conversation
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>
|
|
||
| // 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. |
Contributor
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.
milan-zededa
approved these changes
Mar 31, 2026
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
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
url.JoinPathchange was not in this branch.Checklist
check them.