question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] SAS tokens that start with '?' cause requests to storage to fail

See original GitHub issue

Describe the bug If SAS token begins with ‘?’ (like when copied from Azure Portal), it fails with the below error:

com.azure.storage.blob.models.BlobStorageException: 
Status code 403, 
<?xml version="1.0" encoding="utf-8"?>
  <Error>
      <Code>AuthenticationFailed</Code>
      <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId: redacted Time: redacted</Message> . 
      <AuthenticationErrorDetail>sr is mandatory. Cannot be empty</AuthenticationErrorDetail>
  </Error>

Exception or Stack Trace Added above

To Reproduce Add an existing storage account name in the endpoint below and should be able to reproduce the issue:

String endpoint = "https://<storage_account>.blob.core.windows.net/";
BlobServiceClient client = new BlobServiceClientBuilder()
    .endpoint(endpoint)
    .sasToken("?sv=2019-02-02&ss=bf&srt=sco&sp=rla&se=2019-11-27T16:03:21Z&st=2019-11-27T08:03:21Z&spr=https&sig=NZX%2FZH7GFSPgmb7j62GldqDEW%2BINoFKlAC4euoxM1Xc%3D")
    .buildClient();

BlobServiceProperties properties = client.getProperties();

Code Snippet Added above

Expected behavior SDK should be able to handle both scenarios - a SAS token that begins with ‘?’ and one that does not.

Screenshots NA

Setup (please complete the following information):

  • OS: Linux
  • IDE : IntelliJ
  • Version of the Library used: 12.0.0

Additional context NA

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gapra-msftcommented, Nov 27, 2019

Hi @SukruthKS, you’re right. I wasn’t testing with 12.0.0 so that’s probably why I wasn’t seeing the issue.

As you pointed out a fix for the issue you mentioned was committed so it will be in our next release.

I’ll go ahead and close this issue since you should be resolved by our next release.

1reaction
gapra-msftcommented, Nov 27, 2019

Hi @SukruthKS,

It seems like you are encountering the issue reported here https://github.com/Azure/azure-sdk-for-java/issues/6542.

We are aware of the problem and are currently working on a fix for it.

I will prioritize working on getting this fix out as soon as possible and will keep you posted on the status.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAS error codes (REST API) - Azure Storage - Microsoft Learn
Scenario Storage Error Code Old Http Status... Authorization of IP address or range failed AuthorizationSourceIPMismatch N/A Authorization of HTTPS failed AuthorizationProtocolMismatch N/A Unauthorized signed service AuthorizationServiceMismatch...
Read more >
Failed to fetch valid sas token - Commvault Community
Hi all, i will try here, We have 2 MA in Azure that acts as proxy as well.. When we tried to backup...
Read more >
Getting Error while Creating SAS Token for Azure Storage ...
From this thread: The error is because your oauth account don't have permission to generateUserDelegationKey. To get SAS with Oauth storage ...
Read more >
Avoiding "AuthorizationFailed" error when hand-crafting ...
So let's start! ... Server failed to authenticate the request. ... Storage team has also published a list of SAS error codes and...
Read more >
The remote server returned an error 403 Forbidden SAS URI ...
The remote server returned an error 403 Forbidden SAS URI Azure Blob Storage Azure Data Factory | ADF Tutorial 2022, in this video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found