Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createTableIfNotExists fails with TableNotFound when table does not exist #16

Closed
AleF83 opened this issue Apr 10, 2018 · 4 comments · Fixed by #116
Closed

createTableIfNotExists fails with TableNotFound when table does not exist #16

AleF83 opened this issue Apr 10, 2018 · 4 comments · Fixed by #116
Assignees
Labels
bug Something isn't working enhancement New feature or request table-storage Relating to Azurite table storage implementation

Comments

@AleF83
Copy link

AleF83 commented Apr 10, 2018

I'm using azure/azure-storage-node.
This is the code that fails (in azure/azure-storage-node)

There is the check

else if (responseObject.error && responseObject.error.statusCode === Constants.HttpConstants.HttpResponseCodes.NotFound) {
      responseObject.error = null;
      responseObject.tableResult.exists = false;
      responseObject.response.isSuccessful = true;
    }

But the responseObject is as following:

{ error:
   { StorageError: <?xml version="1.0" encoding="utf-8"?><Error><Code>TableNotFound</Code><Message>The table specified does not exist.</Message></Error>
    at Function.StorageServiceClient._normalizeError (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/azure-storage/lib/common/services/storageserviceclient.js:1153:12)
    at TableService.StorageServiceClient._processResponse (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/azure-storage/lib/common/services/storageserviceclient.js:738:50)
    at Request.processResponseCallback [as _callback] (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/azure-storage/lib/common/services/storageserviceclient.js:311:37)
    at Request.self.callback (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/Users/alexander/Development/Sandbox/azurite-check/node-service/node_modules/request/request.js:1085:12)
     name: 'StorageError',
     message: '<?xml version="1.0" encoding="utf-8"?><Error><Code>TableNotFound</Code><Message>The table specified does not exist.</Message></Error>' },
  response:
   { isSuccessful: false,
     statusCode: 404,
     body: '<?xml version="1.0" encoding="utf-8"?><Error><Code>TableNotFound</Code><Message>The table specified does not exist.</Message></Error>',
     headers:
      { 'x-powered-by': 'Express',
        'content-type': 'text/html; charset=utf-8',
        'content-length': '133',
        etag: 'W/"85-QChnKDYjVl8qDySHFUJOL2CNEFU"',
        date: 'Tue, 10 Apr 2018 08:09:42 GMT',
        connection: 'keep-alive' },
     md5: undefined },
  contentMD5: undefined,
  length: undefined,
  operationEndTime: 2018-04-10T08:09:39.194Z,
  targetLocation: 0,
  outputStreamSent: false,
  tableResult: { isSuccessful: false, statusCode: 404, TableName: 'mytable' } }

So responseObject.error.statusCode is undefined.

@AleF83 AleF83 closed this as completed Apr 10, 2018
@AleF83 AleF83 reopened this Apr 10, 2018
@edwin-huber edwin-huber added the table-storage Relating to Azurite table storage implementation label Apr 30, 2018
@XiaoningLiu XiaoningLiu added the enhancement New feature or request label Jul 24, 2018
@edwin-huber edwin-huber self-assigned this Sep 3, 2018
@edwin-huber
Copy link
Collaborator

We are currently looking at the way we are handling errors and responses, and this is definitely related.
I shall write a test case, as we definitely want to support this azure-storage-node call, and we shall sort it out.
@pdressel please sync with me 😉

@edwin-huber edwin-huber added the bug Something isn't working label Sep 3, 2018
@alexframe
Copy link

Was there any progress with this?

@frenchzed
Copy link

I think this is to be related to the fact that the error response has an incorrect content type (text/html):

HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 135
ETag: W/"87-b2+fEFOsQRVwbcQHbVVBYSt732w"
Date: Sat, 17 Nov 2018 03:56:44 GMT
Connection: keep-alive

If you look at azure-storage library, it clearly expect application/xml or else it doesn't even bother parsing the reponse, therefore not mapping response code properly:

https://github.com/Azure/azure-storage-node/blob/0557d02cd2116046db1a2d7fc61a74aa28c8b557/lib/common/services/storageserviceclient.js#L888

@frenchzed
Copy link

@alexframe, #116 should fix your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request table-storage Relating to Azurite table storage implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants