From e7f01650e349edfd72d02412caac582bad4b3e6d Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 17 Jul 2024 18:05:09 +0000 Subject: [PATCH] Merged PR 41160: Temporarily work around '/' in dSAS Temporarily work around '/' in dSAS When dSAS tokens contain a forward /, helix will incorrectly name the file target for a correlation payload, and then fail to unpack it. ---- #### AI description (iteration 1) #### PR Classification Bug fix to address an issue with SAS tokens containing '/' causing incorrect downloads. #### PR Summary This pull request implements a workaround for a Helix issue where SAS tokens with '/' result in incorrect downloads of correlation payloads. - `eng/common/templates/steps/get-delegation-sas.yml`: Added a loop to regenerate the SAS token if it contains a '/' character, ensuring valid tokens are generated. --- eng/common/templates/steps/get-delegation-sas.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/eng/common/templates/steps/get-delegation-sas.yml b/eng/common/templates/steps/get-delegation-sas.yml index c0e8f91317f..8fea69b6240 100644 --- a/eng/common/templates/steps/get-delegation-sas.yml +++ b/eng/common/templates/steps/get-delegation-sas.yml @@ -28,12 +28,17 @@ steps: # Calculate the expiration of the SAS token and convert to UTC $expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv + # Temporarily work around a helix issue where SAS tokens with / in them will cause incorrect downloads + # of correlation payloads. + $sas = "" + do { + $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to generate SAS token." - exit 1 - } + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to generate SAS token." + exit 1 + } + } while($sas.IndexOf('/') -ne -1) if ('${{ parameters.base64Encode }}' -eq 'true') { $sas = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($sas))